分组推送API
最新更新:2023-03-03
功能说明
该 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。这二者可以在控制台【分组管理】-【编辑】中查看。
调用地址
POST v4/grouppush
POST v4/grouppush
此代码块在浮窗中显示
请求示例
curl --insecure -X POST -v https://push.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://push.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==
此代码块在浮窗中显示
请求参数
请求参数参考 创建推送 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"
}
此代码块在浮窗中显示
失败响应
{
"code":400,
"data":"",
"message":"错误信息"
}
{
"code":400,
"data":"",
"message":"错误信息"
}
此代码块在浮窗中显示
错误码
详情参考 「创建推送 API - 调用返回」。