Logo Site EngageLab Mark Colored Transparent文件
搜尋

分組推送 API

功能說明

此 API 用於建立應用分組推送,一次呼叫即可對該分組下的所有應用進行訊息推送。

  • 暫不支援 option 中的 override_msg_id 屬性。
  • 分組推送僅在控制台推送時支援設定排程任務,不支援呼叫 Schedule API 來設定排程任務。

呼叫驗證

在 HTTP Header(標頭)中加入一個欄位(Key/Value 對):

Authorization: Basic ${base64_auth_string}
              
                  Authorization: Basic ${base64_auth_string}

            
此代碼塊在浮窗中顯示

上述 base64_auth_string 的產生演算法為:base64(username:password)
Header 名稱為 Authorization,值是經過 base64 轉換的 username:password 組合(中間有一個冒號)。
在分組推送 API 的情境中,username 是加上 group- 前綴的 GroupKey,password 是 Group Master Secret。這兩者可在控制台【分組管理】-【編輯】中查看。

image.png

呼叫位址

POST v4/grouppush
              
              POST v4/grouppush

            
此代碼塊在浮窗中顯示

請求範例

curl --insecure -X POST -v https://webpushapi-sgp.engagelab.com/v4/grouppush -H "Content-Type: application/json" -u "c96f42e0d2e662e45d035ab1:df4d59e84eac2f9d53b36f12" -d '{ "from": "push", "to": "all", "body": { "platform": "web", "notification": { "alert": "Hi,MTPush !", "web": { "title": "web_push", "url": "http://www.google.com", "extras": { "web-key1": "web-value1" } } } }, "request_id": "12345678", "custom_args": "business info" }' > POST /v4/grouppush HTTP/1.1 > Authorization: Basic Yzk2ZjQyZTBkMmU2NjJlNDVkMDM1YWIxOmRmNGQ1OWU4NGVhYzJmOWQ1M2IzNmYxMg==
              
              curl --insecure -X POST -v https://webpushapi-sgp.engagelab.com/v4/grouppush
-H "Content-Type: application/json" 
-u "c96f42e0d2e662e45d035ab1:df4d59e84eac2f9d53b36f12" 
-d '{
    "from": "push",
    "to": "all",
    "body": {
        "platform": "web",
        "notification": {
            "alert": "Hi,MTPush !",
            "web": {
                "title": "web_push",
                "url": "http://www.google.com",
                "extras": {
                    "web-key1": "web-value1"
                }
            }
        }
    },
    "request_id": "12345678",
    "custom_args": "business info"
}'
> POST /v4/grouppush HTTP/1.1
> Authorization: Basic Yzk2ZjQyZTBkMmU2NjJlNDVkMDM1YWIxOmRmNGQ1OWU4NGVhYzJmOWQ1M2IzNmYxMg==

            
此代碼塊在浮窗中顯示

請求參數

請求參數請參考建立推送 API

返回範例

成功回應

{ "0c3de43c6a6b68c9f4261b06": {"request_id":"12345678","msg_id":"2460001"}, "35c424abde12f475566ca8af": {"request_id":"12345678","msg_id":"2460001"}, "8f02a4fa717a6235734d92de": {"request_id":"12345678","msg_id":"2460001"}, "group_msgid": "cbou2uum98lps87rtic0" }
              
              {
    "0c3de43c6a6b68c9f4261b06": {"request_id":"12345678","msg_id":"2460001"},
    "35c424abde12f475566ca8af": {"request_id":"12345678","msg_id":"2460001"},
    "8f02a4fa717a6235734d92de": {"request_id":"12345678","msg_id":"2460001"},
    "group_msgid": "cbou2uum98lps87rtic0"
}

            
此代碼塊在浮窗中顯示

失敗回應

{ "error":{ "code":21037, "message":"group_key is not a 24 size string or does not exist" } }
              
              {
    "error":{
            "code":21037,    
            "message":"group_key is not a 24 size string or does not exist"
    }
}

            
此代碼塊在浮窗中顯示

錯誤碼

詳情請參考「建立推送 API - 呼叫返回」

Icon Solid Transparent White Qiyu
聯繫銷售