Group Push API
อัพเดทล่าสุด :2023-03-03
Description
This API is used to create a group push. A call can push messages to all applications in the group.
- The override_msg_id attribute in option is not supported.
- Group push only supports setting scheduled tasks when pushing in the console, but does not support calling Schedule API to set scheduled tasks.
Call Validation
Add a field (Key/Value pair) to the HTTP Header (Header):
Authorization: Basic ${base64_auth_string}
Authorization: Basic ${base64_auth_string}
โค้ดนี้โชว์เป็นหน้าต่างลอย
That is, the base64_auth_string generation algorithm is base64(username:password)
The Header name is "Authorization" and the value is a base64-converted "username:password" pair (with a colon in the middle).
In the scenario of group push API, username is the prefix of "group-" plus GroupKey, and the password is group Master Secret. You can view the two in Group management-edit in the console.
Call Address
POST v4/grouppush
Sample Requests
curl --insecure -X POST -v https://webpush.api.engagelab.cc/v4/grouppush
-H "Content-Type: application/json"
-u "c96f42e0d2e662e45d035ab1:df4d59e84eac2f9d53b36f12"
-d '{
"from": "push",
"to": "all",
"body": {
"platform": "all",
"notification": {
"android": {
"alert": "Hi, Push!",
"title": "Send to Android",
"builder_id": 1,
"extras": {
"newsid": 321
}
},
"ios": {
"alert": "Hi, MTPush!",
"sound": "default",
"badge": "+1",
"extras": {
"newsid": 321
}
}
},
"message": {
"msg_content": "Hi,MTPush",
"content_type": "text",
"title": "msg",
"extras": {
"key": "value"
}
},
"options": {
"time_to_live": 60,
"apns_production": false
}
},
"request_id": "12345678",
"custom_args": "business info"
}'
> POST /v4/grouppush HTTP/1.1
> Authorization: Basic Yzk2ZjQyZTBkMmU2NjJlNDVkMDM1YWIxOmRmNGQ1OWU4NGVhYzJmOWQ1M2IzNmYxMg==
curl --insecure -X POST -v https://webpush.api.engagelab.cc/v4/grouppush
-H "Content-Type: application/json"
-u "c96f42e0d2e662e45d035ab1:df4d59e84eac2f9d53b36f12"
-d '{
"from": "push",
"to": "all",
"body": {
"platform": "all",
"notification": {
"android": {
"alert": "Hi, Push!",
"title": "Send to Android",
"builder_id": 1,
"extras": {
"newsid": 321
}
},
"ios": {
"alert": "Hi, MTPush!",
"sound": "default",
"badge": "+1",
"extras": {
"newsid": 321
}
}
},
"message": {
"msg_content": "Hi,MTPush",
"content_type": "text",
"title": "msg",
"extras": {
"key": "value"
}
},
"options": {
"time_to_live": 60,
"apns_production": false
}
},
"request_id": "12345678",
"custom_args": "business info"
}'
> POST /v4/grouppush HTTP/1.1
> Authorization: Basic Yzk2ZjQyZTBkMmU2NjJlNDVkMDM1YWIxOmRmNGQ1OWU4NGVhYzJmOWQ1M2IzNmYxMg==
โค้ดนี้โชว์เป็นหน้าต่างลอย
Request parameters
For more information about request parameters, see Create Push API 。
Response example
Success
{
"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"
}
โค้ดนี้โชว์เป็นหน้าต่างลอย
Failed
{
"code":400,
"data":"",
"message":"error message"
}
{
"code":400,
"data":"",
"message":"error message"
}
โค้ดนี้โชว์เป็นหน้าต่างลอย
Codes
For more information, see 「Ceate Push API - Response」.