NT Notify API

概述

此 API 提供類似 NT Notify 的功能,允許應用程式向使用者發送通知。您需要生成 API Token 進行身份驗證。

重要提示: 所有請求都必須包含有效的 API Token。
新功能: 我們現在支持針對特定用戶發送、群發和廣播訊息。查看下方文檔了解更多資訊。

API 端點

查詢服務狀態

端點: GET /api/status

描述: 查詢 API 服務狀態。

請求標頭
Authorization: Bearer YOUR_API_TOKEN
成功回應
{
    "status": 200,
    "message": "服務運行中",
    "data": {
        "app": "NT-Notify",
        "status": "ok",
        "server_time": "2026-09-08T12:34:56+08:00"
    }
}
失敗回應
{
    "status": 401,
    "message": "Token 無效或未提供"
}
回應參數說明
參數名稱 類型 描述
status integer HTTP 狀態碼
message string 狀態訊息
data.app string 服務名稱
data.status string 服務狀態,固定為 ok
data.server_time string 伺服器目前時間(ISO 8601 格式)
範例
curl -X GET \
  /api/status \
  -H 'Authorization: Bearer YOUR_API_TOKEN'
<?php
$ch = curl_init();

curl_setopt_array($ch, [
    CURLOPT_URL => '/api/status',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer YOUR_API_TOKEN',
    ],
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
fetch('/api/status', {
    method: 'GET',
    headers: {
        'Authorization': 'Bearer YOUR_API_TOKEN'
    }
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
發送通知

端點: POST /api/notify

描述: 發送通知訊息。

請求標頭
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json
請求參數
參數名稱 類型 必填 描述
message string 要發送的訊息內容 (最多 5000 字元)
title string 訊息標題 (最多 255 字元)
image_url string 要附加的圖片 URL
recipient_id string 指定單一接收者的 LINE 用戶 ID
recipient_ids array 指定多個接收者的 LINE 用戶 ID 陣列,用於群發訊息 (最多 500 位)
send_to_all boolean 是否發送給所有會員 (廣播),設為 true 時需謹慎使用
recipient_group_id string 指定單一接收群組的 LINE 群組 ID
recipient_group_ids array 或 string 指定多個接收群組的 LINE 群組 ID 陣列。也可以用逗號分隔的字串,例如: "id1,id2,id3"
注意: recipient_id、recipient_ids、recipient_group_id、recipient_group_ids 和 send_to_all 參數不能同時使用。您只能選擇其中一種發送方式。如果都不指定,則使用預設接收者。
成功回應
{
    "success": true,
    "message": "訊息已發送",
    "data": {
        "recipients_count": 1,
        "sent_at": "2023-10-15T12:34:56Z"
    }
}
失敗回應
{
    "success": false,
    "message": "驗證失敗",
    "errors": {
        "message": ["訊息內容不能為空"]
    }
}
回應參數說明
參數名稱 類型 描述
success boolean 是否成功 (true: 成功, false: 失敗)
message string 狀態訊息
data.recipients_count integer 接收訊息的用戶數量 (僅在成功時提供)
data.sent_at string 訊息發送時間 (ISO 8601 格式,僅在成功時提供)
errors object 驗證錯誤訊息 (僅在參數驗證失敗時提供)
使用範例
# 基本發送
curl -X POST \
  /api/notify \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
      "message": "Hello World",
      "title": "通知標題",
      "image_url": "https://example.com/image.jpg"
  }'

# 發送給特定用戶
curl -X POST \
  /api/notify \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
      "message": "This is a personal message",
      "title": "個人通知",
      "recipient_id": "U4af4980629..."
  }'

# 群發給多個用戶
curl -X POST \
  /api/notify \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
      "message": "This is a group message",
      "title": "群組通知",
      "recipient_ids": ["U4af4980629...", "U8c6d6tx42b..."]
  }'

# 廣播給所有用戶
curl -X POST \
  /api/notify \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
      "message": "This is a broadcast message",
      "title": "廣播通知",
      "send_to_all": true
  }'
<?php
/**
 * 發送簡單通知訊息
 */
function sendNotification($message, $title = null, $imageUrl = null) {
    $apiUrl = 'https://notify.example.com/api/notify';
    $apiToken = 'YOUR_API_TOKEN_HERE';
    
    // 準備請求資料
    $data = [
        'message' => $message
    ];
    
    // 如果有標題,加入 data
    if (!empty($title)) {
        $data['title'] = $title;
    }
    
    // 如果有圖片 URL,加入 data
    if (!empty($imageUrl)) {
        $data['image_url'] = $imageUrl;
    }
    
    // 初始化 cURL
    $ch = curl_init($apiUrl);
    
    // 設定 cURL 選項
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Content-Type: application/json',
        'Authorization: Bearer ' . $apiToken
    ]);
    
    // 執行 cURL 請求
    $response = curl_exec($ch);
    curl_close($ch);
    
    return json_decode($response, true);
}

/**
 * 發送訊息給特定使用者
 */
function sendToUser($message, $recipientId, $title = null, $imageUrl = null) {
    $apiUrl = 'https://notify.example.com/api/notify';
    $apiToken = 'YOUR_API_TOKEN_HERE';
    
    // 準備請求資料
    $data = [
        'message' => $message,
        'recipient_id' => $recipientId
    ];
    
    // 如果有標題,加入 data
    if (!empty($title)) {
        $data['title'] = $title;
    }
    
    // 如果有圖片 URL,加入 data
    if (!empty($imageUrl)) {
        $data['image_url'] = $imageUrl;
    }
    
    // 初始化 cURL
    $ch = curl_init($apiUrl);
    
    // 設定 cURL 選項
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Content-Type: application/json',
        'Authorization: Bearer ' . $apiToken
    ]);
    
    // 執行 cURL 請求
    $response = curl_exec($ch);
    curl_close($ch);
    
    return json_decode($response, true);
}

// 使用範例
// sendNotification('這是一條通知訊息', '測試標題');
// sendToUser('這是發送給特定用戶的訊息', 'U4af4980629...', '個人通知');
import requests
import json

# 設定 NT-Notify API 的 URL 和 API Token
API_URL = 'https://notify.example.com/api/notify'
API_TOKEN = 'YOUR_API_TOKEN_HERE'  # 請將此替換為您的實際 API Token


def send_notification(message, title=None, image_url=None):
    """
    發送簡單通知訊息
    """
    # 準備請求資料
    data = {'message': message}
    
    # 如果有標題,加入 data
    if title:
        data['title'] = title
    
    # 如果有圖片 URL,加入 data
    if image_url:
        data['image_url'] = image_url
    
    # 設定請求標頭
    headers = {
        'Content-Type': 'application/json',
        'Authorization': f'Bearer {API_TOKEN}'
    }
    
    # 發送 API 請求
    response = requests.post(API_URL, headers=headers, json=data)
    
    return response.json()


def send_to_user(message, recipient_id, title=None, image_url=None):
    """
    發送訊息給特定使用者
    """
    # 準備請求資料
    data = {
        'message': message,
        'recipient_id': recipient_id
    }
    
    # 如果有標題,加入 data
    if title:
        data['title'] = title
    
    # 如果有圖片 URL,加入 data
    if image_url:
        data['image_url'] = image_url
    
    # 設定請求標頭
    headers = {
        'Content-Type': 'application/json',
        'Authorization': f'Bearer {API_TOKEN}'
    }
    
    # 發送 API 請求
    response = requests.post(API_URL, headers=headers, json=data)
    
    return response.json()

# 使用範例
# result = send_notification("這是一條測試訊息", "測試標題")
# print(result)
// 設定 API 相關常數
const API_URL = '/api/notify';
const API_TOKEN = 'YOUR_API_TOKEN';

/**
 * 發送基本通知
 */
async function sendNotification(message, title, imageUrl) {
    // 準備請求資料
    const data = { message };
    
    // 如果有標題,加入 data
    if (title) {
        data.title = title;
    }
    
    // 如果有圖片 URL,加入 data
    if (imageUrl) {
        data.image_url = imageUrl;
    }
    
    try {
        const response = await fetch(API_URL, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'Authorization': `Bearer ${API_TOKEN}`
            },
            body: JSON.stringify(data)
        });
        
        return await response.json();
    } catch (error) {
        console.error('Error:', error);
        return { success: false, message: error.message };
    }
}

/**
 * 發送訊息給特定用戶
 */
async function sendToUser(message, recipientId, title, imageUrl) {
    // 準備請求資料
    const data = { 
        message,
        recipient_id: recipientId
    };
    
    // 如果有標題,加入 data
    if (title) {
        data.title = title;
    }
    
    // 如果有圖片 URL,加入 data
    if (imageUrl) {
        data.image_url = imageUrl;
    }
    
    try {
        const response = await fetch(API_URL, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'Authorization': `Bearer ${API_TOKEN}`
            },
            body: JSON.stringify(data)
        });
        
        return await response.json();
    } catch (error) {
        console.error('Error:', error);
        return { success: false, message: error.message };
    }
}

// 使用範例
// sendNotification('Hello World', '通知標題', 'https://example.com/image.jpg')
//   .then(data => console.log(data));
// 設定 NT-Notify API 的 URL 和 API Token
var API_URL = 'https://notify.example.com/api/notify';
var API_TOKEN = 'YOUR_API_TOKEN_HERE'; // 請將此替換為您的實際 API Token

/**
 * 發送單一訊息通知
 */
function sendNotification(message, title, imageUrl) {
  // 準備請求資料
  var payload = {
    'message': message
  };
  
  // 如果有標題,加入 payload
  if (title && title.trim() !== '') {
    payload.title = title;
  }
  
  // 如果有圖片 URL,加入 payload
  if (imageUrl && imageUrl.trim() !== '') {
    payload.image_url = imageUrl;
  }
  
  // 設定 API 請求選項
  var options = {
    'method': 'post',
    'contentType': 'application/json',
    'headers': {
      'Authorization': 'Bearer ' + API_TOKEN
    },
    'payload': JSON.stringify(payload),
    'muteHttpExceptions': true
  };
  
  // 發送 API 請求
  var response = UrlFetchApp.fetch(API_URL, options);
  
  // 解析 API 回應
  var result = JSON.parse(response.getContentText());
  
  // 記錄結果
  Logger.log('發送結果: ' + result.message);
  
  return result;
}

/**
 * 發送訊息給特定使用者
 */
function sendToUser(message, recipientId, title, imageUrl) {
  // 準備請求資料
  var payload = {
    'message': message,
    'recipient_id': recipientId
  };
  
  // 如果有標題,加入 payload
  if (title && title.trim() !== '') {
    payload.title = title;
  }
  
  // 如果有圖片 URL,加入 payload
  if (imageUrl && imageUrl.trim() !== '') {
    payload.image_url = imageUrl;
  }
  
  // 設定 API 請求選項
  var options = {
    'method': 'post',
    'contentType': 'application/json',
    'headers': {
      'Authorization': 'Bearer ' + API_TOKEN
    },
    'payload': JSON.stringify(payload),
    'muteHttpExceptions': true
  };
  
  // 發送 API 請求
  var response = UrlFetchApp.fetch(API_URL, options);
  
  return JSON.parse(response.getContentText());
}

/**
 * 發送訊息給特定群組
 */
function sendToSpecificGroup() {
  sendWebhook('這是發送給特定群組的訊息', {
    'recipient_group_id': 'C4af4980629...'
  });
}

/**
 * 群發訊息給多個群組
 */
function sendToMultipleGroups() {
  sendWebhook('這是群發給多個群組的訊息', {
    'recipient_group_ids': ['C4af4980629...', 'C8c6d6tx42b...']
  });
}

// 使用範例
// function testNotify() {
//   sendNotification('這是一條通知訊息', '測試標題');
// }
樣本程式碼

您可以下載以下完整的範例程式碼:


取得訊息紀錄

本系統提供 API 查詢 LINE Bot 收到的訊息紀錄,支援多種篩選條件。認證方式與其他端點相同,使用 API TokenAuthorization: Bearer YOUR_API_TOKEN),無需另外登入取得 Token。

取得所有 Bot 的接收訊息(跨 Bot 查詢)

端點: GET /api/messages

描述: 查詢目前登入使用者旗下「所有 Bot」接收到的訊息,可加上 bot_id 參數縮小範圍,適合跨 Bot 統一查詢。

請求標頭
Authorization: Bearer YOUR_API_TOKEN
查詢參數
參數名稱 類型 必填 描述
bot_id integer 篩選特定 Bot(不填則查詢所有 Bot)
line_user_id string 篩選特定 LINE 用戶
line_group_id string 篩選特定 LINE 群組
source_type string usergroup
message_type string 訊息類型:textimagesticker
start_date string 起始日期,格式 Y-m-d
end_date string 結束日期,格式 Y-m-d
per_page integer 每頁筆數(預設 15,最大 100)
使用範例
# 查詢所有 Bot 的接收訊息
curl -X GET "http://YOUR_DOMAIN/api/messages?per_page=20" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

# 篩選某日期範圍內的群組訊息
curl -X GET "http://YOUR_DOMAIN/api/messages?source_type=group&start_date=2024-01-01&end_date=2024-01-31" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

# 特定 Bot + 特定用戶
curl -X GET "http://YOUR_DOMAIN/api/messages?bot_id=1&line_user_id=U4af4980629..." \
  -H "Authorization: Bearer YOUR_API_TOKEN"
<?php
$apiUrl = 'https://YOUR_DOMAIN/api/messages';
$apiToken = 'YOUR_API_TOKEN';

$params = http_build_query([
    'source_type' => 'user',
    'start_date'  => '2024-01-01',
    'end_date'    => '2024-01-31',
    'per_page'    => 20,
]);

$ch = curl_init();
curl_setopt_array($ch, [
    CURLOPT_URL => $apiUrl . '?' . $params,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => ["Authorization: Bearer {$apiToken}"],
]);

$response = json_decode(curl_exec($ch), true);
curl_close($ch);

echo "共 " . $response['data']['total'] . " 則訊息\n";
foreach ($response['data']['data'] as $msg) {
    echo "[{$msg['created_at']}] {$msg['content']}\n";
}
const apiToken = 'YOUR_API_TOKEN';

async function getAllMessages(filters = {}) {
    const params = new URLSearchParams(filters).toString();
    const res = await fetch(`/api/messages?${params}`, {
        headers: { 'Authorization': `Bearer ${apiToken}` }
    });
    return await res.json();
}

// 查詢所有 Bot 今日的個人訊息
const today = new Date().toISOString().split('T')[0];
getAllMessages({ source_type: 'user', start_date: today })
    .then(data => {
        console.log(`共 ${data.data.total} 則訊息`);
        data.data.data.forEach(msg => {
            console.log(`[${msg.created_at}] ${msg.content}`);
        });
    });

群組分類

群組管理支援自訂分類(category / subcategory / tags / note),可用於「一群一個倉庫」的分群檢視。認證方式:API TokenAuthorization: Bearer YOUR_API_TOKEN)。

取得群組清單(含分類資訊)

端點: GET /api/groups

描述: 取得目前 Token 擁有者名下所有群組,可用 bot_idcategory 篩選。

請求標頭
Authorization: Bearer YOUR_API_TOKEN
查詢參數
參數名稱類型必填描述
bot_idinteger篩選特定 Bot
categorystring篩選特定分類
成功回應
{
    "status": 200,
    "message": "取得群組清單成功",
    "data": [
        {
            "id": 1,
            "user_bot_id": 1,
            "line_group_id": "Cd48b3679f5e6564d8fdd2b180e518376",
            "group_name": "丟資料用",
            "category": "測試",
            "subcategory": null,
            "tags": null,
            "note": null,
            "created_at": "2026-09-07T22:30:30+08:00"
        }
    ]
}
錯誤回應
狀態碼說明
401Token 無效或未提供
更新單個群組的分類資訊

端點: PUT /api/groups/{id}/taxonomy

描述: {id} 為群組在本系統的內部 ID(GET /api/groups 回應中的 id,非 line_group_id)。

請求標頭
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json
請求參數
參數名稱類型必填描述
categorystring分類(最多 255 字元)
subcategorystring子分類(最多 255 字元)
tagsarray<string>標籤(多值)
notestring備註
成功回應
{
    "status": 200,
    "message": "群組分類更新成功",
    "data": { "id": 1, "category": "測試", "subcategory": null, "tags": null, "note": null }
}
錯誤回應
狀態碼說明
401Token 無效或未提供
403該群組不屬於目前 Token 的擁有者
404找不到指定的群組
422參數驗證失敗
範例
curl -X PUT "http://YOUR_DOMAIN/api/groups/1/taxonomy" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"category": "測試", "tags": ["重要", "供應商"]}'

群組訊息匯出

把某個群組的訊息一次匯出(文字格式 + 媒體 ZIP),採非同步處理:先建立匯出工作,再輪詢工作狀態取得下載連結。認證方式:API Token

建立群組訊息匯出工作

端點: POST /api/groups/{line_group_id}/exports

描述: {line_group_id} 為 LINE 群組 ID(例如 Cd48b3679f5e6564d8fdd2b180e518376)。

請求標頭
Authorization: Bearer YOUR_API_TOKEN
請求參數
參數名稱類型必填描述
formatstringtxtcsv(預設)或 jsonl
start_datestring起始日期,格式 Y-m-d
end_datestring結束日期,格式 Y-m-d
include_mediaboolean是否一併打包照片/影片/檔案的 ZIP
message_typestring篩選訊息類型
成功回應(202)
{
    "status": 202,
    "message": "匯出工作已建立",
    "job_id": 1,
    "export_status": "pending"
}
錯誤回應
狀態碼說明
401Token 無效或未提供
404找不到群組或沒有權限
422參數驗證失敗
範例
curl -X POST "http://YOUR_DOMAIN/api/groups/Cd48b3679f5e6564d8fdd2b180e518376/exports" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -d "format=csv&include_media=1"
查詢匯出工作狀態

端點: GET /api/exports/{job_id}

描述: {job_id} 為建立匯出工作時回傳的 job_id

成功回應
{
    "status": 200,
    "message": "取得匯出工作狀態成功",
    "data": {
        "job_id": 1,
        "status": "completed",
        "file_url": "https://.../exports/xxx.zip",
        "expires_at": "2026-09-09T22:30:30+08:00",
        "error": null
    }
}

status 可能為 pendingprocessingcompletedfailedfile_url 只在 completed 且未過期時提供,下載連結有效期限至少 24 小時。

錯誤回應
狀態碼說明
401Token 無效或未提供
404找不到匯出工作或沒有權限

群組歷史聊天紀錄匯入

把 bot 加入群組前的歷史對話(LINE App 匯出的 .txt)與照片/影片補進同一個群組的倉庫,一併採非同步處理。認證方式:API Token

建立歷史聊天紀錄匯入工作

端點: POST /api/groups/{line_group_id}/imports

描述: multipart/form-data 上傳。

請求標頭
Authorization: Bearer YOUR_API_TOKEN
Content-Type: multipart/form-data
請求參數
參數名稱類型必填描述
chat_txtfileLINE App 匯出的聊天紀錄 .txt(最大 5MB)
media[]file[]照片/影片/檔案,可多個(每個最大 50MB)
name_mapstring(JSON)「.txt 顯示名稱 → 會員」對應表,例如 {"TK Lin": "U4af..."}
成功回應(202)
{
    "status": 202,
    "message": "匯入工作已建立",
    "job_id": 1,
    "import_status": "pending"
}
錯誤回應
狀態碼說明
401Token 無效或未提供
404找不到群組或沒有權限
422參數錯誤(檔案格式/大小、name_map 非合法 JSON 等)
範例
curl -X POST "http://YOUR_DOMAIN/api/groups/Cd48b3679f5e6564d8fdd2b180e518376/imports" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -F "chat_txt=@/path/to/chat.txt" \
  -F "media[]=@/path/to/photo1.jpg" \
  -F "media[]=@/path/to/photo2.jpg" \
  -F 'name_map={"TK Lin":"U4af4980629..."}'
查詢匯入工作狀態

端點: GET /api/imports/{job_id}

成功回應
{
    "status": 200,
    "message": "取得匯入工作狀態成功",
    "data": {
        "id": 1,
        "group_id": "Cd48b3679f5e6564d8fdd2b180e518376",
        "status": "completed",
        "stats": { "inserted": 12, "skipped": 0, "media_matched": 2, "media_unmatched": 0 },
        "error_message": null
    }
}

status 可能為 pendingprocessingcompletedfailedstats 內容依實際解析結果而定。

錯誤回應
狀態碼說明
401Token 無效或未提供
404找不到匯入工作或沒有權限
撤銷整批匯入

端點: DELETE /api/imports/{job_id}

描述: 刪除該匯入批次寫入的所有訊息(origin = import),webhook 收到的訊息不受影響。

成功回應
{
    "status": 200,
    "message": "匯入批次已撤銷",
    "deleted_count": 12
}
錯誤回應
狀態碼說明
401Token 無效或未提供
404找不到匯入工作或沒有權限
範例
curl -X DELETE "http://YOUR_DOMAIN/api/imports/1" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Webhooks

本系統提供 Webhook URL,您可以通過 HTTP 請求直接發送訊息而無需使用 API Token。

使用 Webhook URL 發送通知

端點: POST 您的 Webhook URL

描述: 使用 Webhook URL 直接發送通知訊息。

獲取方式: 在 Bot 管理頁面中可以看到每個 Bot 生成的唯一 Webhook URL。

新功能: 現在支援指定特定用戶 ID 發送訊息、群發訊息以及添加標題和圖片!
請求參數
參數名稱 類型 必填 描述
message string 要發送的訊息內容(最多 5000 字元)
title string 訊息標題(最多 255 字元),會顯示在訊息開頭
image_url string 要附加的圖片 URL(必須是公開可訪問的圖片)
recipient_id string 指定單一接收者的 LINE 用戶 ID
recipient_ids array 或 string 指定多個接收者的 LINE 用戶 ID 陣列,最多 500 個。也可以用逗號分隔的字串,例如: "id1,id2,id3"
send_to_all boolean 是否發送給所有會員(廣播,需謹慎使用)
recipient_group_id string 指定單一接收群組的 LINE 群組 ID
recipient_group_ids array 或 string 指定多個接收群組的 LINE 群組 ID 陣列。也可以用逗號分隔的字串,例如: "id1,id2,id3"
注意: recipient_id、recipient_ids、recipient_group_id、recipient_group_ids 和 send_to_all 參數不能同時使用。您只能選擇其中一種發送方式。如果都不指定,則使用預設接收者。
成功回應
{
    "status": "success",
    "message": "訊息發送成功",
    "data": {
        "recipients_count": 1,
        "sent_at": "2023-12-31T12:34:56"
    }
}
失敗回應
{
    "status": "error",
    "message": "錯誤訊息",
    "errors": {
        "message": ["訊息內容不能為空"]
    }
}
範例
# 基本用法
curl -X POST \
  "YOUR_WEBHOOK_URL" \
  -H 'Content-Type: application/json' \
  -d '{"message":"Hello World"}'

# 添加標題和圖片
curl -X POST \
  "YOUR_WEBHOOK_URL" \
  -H 'Content-Type: application/json' \
  -d '{
    "message":"這是訊息內容", 
    "title":"訊息標題", 
    "image_url":"https://example.com/image.jpg"
  }'

# 發送給特定用戶
curl -X POST \
  "YOUR_WEBHOOK_URL" \
  -H 'Content-Type: application/json' \
  -d '{
    "message":"這是發送給特定用戶的訊息", 
    "recipient_id":"U4af4980629..."
  }'

# 群發給多個用戶
curl -X POST \
  "YOUR_WEBHOOK_URL" \
  -H 'Content-Type: application/json' \
  -d '{
    "message":"這是群發訊息", 
    "recipient_ids":["U4af4980629...", "U8c6d6tx42b..."]
  }'

# 發送給特定群組
curl -X POST \
  "YOUR_WEBHOOK_URL" \
  -H 'Content-Type: application/json' \
  -d '{
    "message":"這是發送給特定群組的訊息", 
    "recipient_group_id":"C4af4980629..."
  }'

# 群發給多個群組
curl -X POST \
  "YOUR_WEBHOOK_URL" \
  -H 'Content-Type: application/json' \
  -d '{
    "message":"這是群發給多個群組的訊息", 
    "recipient_group_ids":["C4af4980629...", "C8c6d6tx42b..."]
  }'
<?php
$webhookUrl = 'YOUR_WEBHOOK_URL';

// 基本用法
function sendWebhook($message, $extraParams = []) {
    global $webhookUrl;
    
    // 準備請求資料
    $data = array_merge(['message' => $message], $extraParams);
    
    // 初始化 cURL
    $ch = curl_init($webhookUrl);
    curl_setopt_array($ch, [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POST => true,
        CURLOPT_POSTFIELDS => json_encode($data),
        CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
    ]);

    // 執行請求
    $response = curl_exec($ch);
    $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    
    return [
        'code' => $statusCode,
        'response' => json_decode($response, true)
    ];
}

// 發送基本訊息
$result = sendWebhook('Hello World');

// 添加標題和圖片
$result = sendWebhook('這是訊息內容', [
    'title' => '訊息標題',
    'image_url' => 'https://example.com/image.jpg'
]);

// 發送給特定用戶
$result = sendWebhook('這是發送給特定用戶的訊息', [
    'recipient_id' => 'U4af4980629...'
]);

// 群發給多個用戶
$result = sendWebhook('這是群發訊息', [
    'recipient_ids' => ['U4af4980629...', 'U8c6d6tx42b...']
]);

// 發送給特定群組
$result = sendWebhook('這是發送給特定群組的訊息', [
    'recipient_group_id' => 'C4af4980629...'
]);

// 群發給多個群組
$result = sendWebhook('這是群發給多個群組的訊息', [
    'recipient_group_ids' => ['C4af4980629...', 'C8c6d6tx42b...']
]);
const webhookUrl = 'YOUR_WEBHOOK_URL';

// 基本發送函數
async function sendWebhook(message, extraParams = {}) {
    try {
        const response = await fetch(webhookUrl, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
            },
            body: JSON.stringify({
                message,
                ...extraParams
            })
        });
        
        return await response.json();
    } catch (error) {
        console.error('Error:', error);
        return { status: 'error', message: error.message };
    }
}

// 基本用法
sendWebhook('Hello World')
    .then(result => console.log(result));

// 添加標題和圖片
sendWebhook('這是訊息內容', {
    title: '訊息標題',
    image_url: 'https://example.com/image.jpg'
}).then(result => console.log(result));

// 發送給特定用戶
sendWebhook('這是發送給特定用戶的訊息', {
    recipient_id: 'U4af4980629...'
}).then(result => console.log(result));

// 群發給多個用戶
sendWebhook('這是群發訊息', {
    recipient_ids: ['U4af4980629...', 'U8c6d6tx42b...']
}).then(result => console.log(result));

// 發送給特定群組
sendWebhook('這是發送給特定群組的訊息', {
    recipient_group_id: 'C4af4980629...'
}).then(result => console.log(result));

// 群發給多個群組
sendWebhook('這是群發給多個群組的訊息', {
    recipient_group_ids: ['C4af4980629...', 'C8c6d6tx42b...']
}).then(result => console.log(result));
// Google Apps Script 範例

// 設定 Webhook URL
var WEBHOOK_URL = 'YOUR_WEBHOOK_URL';

/**
 * 基本發送函數
 * 
 * @param  {string} message 訊息內容
 * @param  {object} extraParams 額外參數
 * @return  {object} API 回應
 */
function sendWebhook(message, extraParams) {
  // 準備請求資料
  var payload = {
    'message': message
  };
  
  // 合併額外參數
  if (extraParams) {
    for (var key in extraParams) {
      payload[key] = extraParams[key];
    }
  }
  
  // 設定 API 請求選項
  var options = {
    'method': 'post',
    'contentType': 'application/json',
    'payload': JSON.stringify(payload),
    'muteHttpExceptions': true
  };
  
  // 發送 API 請求
  var response = UrlFetchApp.fetch(WEBHOOK_URL, options);
  
  // 解析 API 回應
  var result = JSON.parse(response.getContentText());
  
  // 記錄結果
  Logger.log('發送結果: ' + result.message);
  
  return result;
}

/**
 * 發送基本訊息
 */
function sendBasicMessage() {
  sendWebhook('Hello World');
}

/**
 * 發送帶標題和圖片的訊息
 */
function sendRichMessage() {
  sendWebhook('這是訊息內容', {
    'title': '訊息標題',
    'image_url': 'https://example.com/image.jpg'
  });
}

/**
 * 發送訊息給特定用戶
 */
function sendToSpecificUser() {
  sendWebhook('這是發送給特定用戶的訊息', {
    'recipient_id': 'U4af4980629...'
  });
}

/**
 * 群發訊息給多個用戶
 */
function sendToMultipleUsers() {
  sendWebhook('這是群發訊息', {
    'recipient_ids': ['U4af4980629...', 'U8c6d6tx42b...']
  });
}

/**
 * 發送訊息給特定群組
 */
function sendToSpecificGroup() {
  sendWebhook('這是發送給特定群組的訊息', {
    'recipient_group_id': 'C4af4980629...'
  });
}

/**
 * 群發訊息給多個群組
 */
function sendToMultipleGroups() {
  sendWebhook('這是群發給多個群組的訊息', {
    'recipient_group_ids': ['C4af4980629...', 'C8c6d6tx42b...']
  });
}

/**
 * 與 Google Sheet 整合範例
 * 根據試算表內容發送訊息
 */
function sendMessagesFromSheet() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var dataRange = sheet.getRange("A2:C" + sheet.getLastRow());
  var data = dataRange.getValues();
  
  for (var i = 0; i < data.length; i++) {
    var row = data[i];
    var message = row[0];  // A列:訊息內容
    var userId = row[1];   // B列:LINE用戶ID
    var isSent = row[2];   // C列:是否已發送
    
    // 如果尚未發送
    if (!isSent) {
      // 發送訊息
      var result = sendWebhook(message, {
        'recipient_id': userId
      });
      
      // 如果發送成功,標記為已發送
      if (result.status === 'success') {
        sheet.getRange(i + 2, 3).setValue(true);
      }
    }
  }
}