2
A
回答
4
<?PHP
function sendMessage(){
$content = array(
"en" => 'Testing Message'
);
$fields = array(
'app_id' => "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx",
'included_segments' => array('All'),
'data' => array("foo" => "bar"),
'large_icon' =>"ic_launcher_round.png",
'contents' => $content
);
$fields = json_encode($fields);
print("\nJSON sent:\n");
print($fields);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/notifications");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8',
'Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
$response = sendMessage();
$return["allresponses"] = $response;
$return = json_encode($return);
print("\n\nJSON received:\n");
print($return);
print("\n");
?>
2
我看到你设置了isAndroid = true,但OneSignal返回一个错误,显示ID为eec33e8e-5774-4b74-9aae-37370778c4b2
的应用程序没有启用Android通知。
请确保您的应用ID是正确的,如果是,则在OneSignal设置中启用Android通知。
相关问题
- 1. 使用Malcom API发送推送通知
- 2. 推送通知:如何使用Pubnub向特定设备发送推送通知?
- 3. 如何使用yammer api发送推送通知
- 4. 从PHP发送iOS推送通知
- 5. 使用Google GCM发送推送通知
- 6. 如何用普通的php发送苹果mdm推送通知?
- 7. 使用API时,Firebase API未发送推送通知
- 8. 使用volley发送firebase推送通知
- 9. iPhone推送通知(PHP)不发送
- 10. 在android中使用php发送推送通知使用php
- 11. 使用推送通知使用Api
- 12. Web推送通知:如何使用Web推送PHP库?
- 13. 如何发送推送通知到arduino
- 14. 如何发送推送通知
- 15. 如何发送推送通知
- 16. 如何发送推送通知?
- 17. 如何发送推送通知
- 18. 如何发送推送通知Firebase
- 19. PHP - 推送通知
- 20. 使用Malcom API向特定用户发送推送通知
- 21. 使用Parse发送推送通知并使用django发送webservices
- 22. 发送通用推送通知 - Xcode
- 23. 如何使用Delphi通过Parse.Com发送推送通知?
- 24. 如何使用Facebook API发送通知?
- 25. 使用raix发送推送通知时没有任何事情发生:推送
- 26. 使用Rest API在parse.com中发送高级推送通知
- 27. iOS推送通知发送错误
- 28. 删除推送通知API?
- 29. 苹果推送通知 - PHP
- 30. 如何使用GCM向特定用户发送推送通知
在他们的网站上有一个PHP示例:https://documentation.onesignal.com/v2.0/docs/notifications-create-notification。那是你在找什么? – Schore
offcourse,根据我做的文件,但它显示这样的错误 – user3544256
JSON发送:{“app_id”:“eec33e8e-5774-4b74-9aae-37370778c4b2”,“included_segments”:[“All”],“send_after”:“ 2014年5月02日00:00:00 GMT-0700(PDT)“,”data“:{”foo“:”bar“},”isAndroid“:true,”contents“:{”en“:” }}收到的JSON:{“allresponses”:“{\”id \“:\”\“,\”recipients \“:0,\”errors \“:[\”All included players not subscribe \“] \“warnings \”:[\“如果您希望向Android播放器发送消息,您必须在OneSignal设置中配置Android通知。”}}“} – user3544256