-2
阅读文档后,我试图写下面的源:附表urbanairship推送通知
$contents = array();
//$contents['badge'] = "+1";
$contents['alert'] = "Touchdown!";
//$contents['sound'] = "cat.caf";
$notification = array();
$notification= $contents;
$audience['tag'] = "49ers";
$scheduled['scheduled_time'] = "2013-04-01T18:45:30";
$push['push'] = array("audience"=> $audience, "notification"=>$notification, "device_types"=>"all");
$response = array();
array_push($response, array("name" => "My schedule", "schedule"=> $scheduled));
array_push($response, $push);
$json = json_encode($response);
//echo "Payload: " . $json . "\n"; //show the payload
$session = curl_init(PUSHURL);
curl_setopt($session, CURLOPT_USERPWD, APPKEY . ':' . PUSHSECRET);
curl_setopt($session, CURLOPT_POST, True);
curl_setopt($session, CURLOPT_POSTFIELDS, $json);
curl_setopt($session, CURLOPT_HEADER, False);
curl_setopt($session, CURLOPT_RETURNTRANSFER, True);
curl_setopt($session, CURLOPT_HTTPHEADER, array('Content-Type:application/json', 'Accept: application/vnd.urbanairship+json; version=3;'));
$content = curl_exec($session);
// echo "Response: " . $content . "\n";
print_r($content);
// Check if any error occured
$response = curl_getinfo($session);
if($response['http_code'] != 202) {
$error = "Got negative response from server: " . $response['http_code'] . "\n";
} else {
$success = "Message has been sent successfully";
}
我收到错误= 0 谁能帮助我吗?
谢谢。
你调度消息2013 ....我假设需要被预定为将来计划的消息。 – dperconti
感谢您的回复。试图把2016年,但仍然没有工作。在响应代码中获得0。 –
你能否通过Urban Airship获得正常的推送通知? – dperconti