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