我想爲OneSignal發送預定的消息,但不是使用他們的儀表板我想使用API來做到這一點,我沒有閱讀他們的文檔,但我找不到任何東西來修改它們的當前API這樣我就可以發送預定通知OneSignal - 發送預定的通知
function sendMessage(){
$content = array(
"en" => $message,
);
$fields = array(
'app_id' => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
'included_segments' => array('All'),
'data' => array("foo" => "bar"),
'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 NGEwMGZmMjItY2NkNy0xMWUzLTk5ZDUtMDAwYzI5NDBlNjJj'));
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");
謝謝您的幫助,我不不知道我錯過了選擇 – Nouf