gpt4 book ai didi

api - OneSignal-发送计划的通知

转载 作者:行者123 更新时间:2023-12-03 16:08:36 28 4
gpt4 key购买 nike

我想发送OneSignal的预定消息,但是我不想使用他们的仪表板,而是想使用API​​来做到这一点,我确实阅读了他们的文档,但是找不到任何可以修改其当前API的东西,所以我可以发送预定的通知

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");

最佳答案

您可以在以下文档页面上找到计划选项:https://documentation.onesignal.com/v3.0/reference#section-delivery

以下是可用的选项:

send_after (Send at a later time)

Examples:

"Thu Sep 24 2015 14:00:00 GMT-0700 (PDT)"

"September 24th 2015, 2:00:00 pm UTC-07:00"

"2015-09-24 14:00:00 GMT-0700"

"Sept 24 2015 14:00:00 GMT-0700"

"Thu Sep 24 2015 14:00:00 GMT-0700 (Pacific Daylight Time)"

delayed_option

Possible values are:

"timezone" (Deliver at a specific time-of-day in each users own timezone)

"last-active" (Deliver at the predicted best time of day to each user).

delivery_time_of_day Use with delayed_option=timezone.

Example:

"9:00AM"



您可以将这些选项添加到代码的字段部分,如下所示:
$fields = array(
'app_id' => "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
'included_segments' => array('All'),
'data' => array("foo" => "bar"),
'contents' => $content,
'send_after' => "Sept 24 2017 14:00:00 GMT-0700"
);

关于api - OneSignal-发送计划的通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45670594/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com