我创建了一个php文件,用于向我的设备发送示例通知:
<?php
$ch = curl_init();
$url = "https://api.usergrid.com/ratnhanhgon/thd/devices/*/notifications";
$send = "payload=exam:hello";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $send);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$out = curl_exec ($ch);
echo $out;
?>
但是当我运行它时,我收到了以下错误消息:
{"error":"web_application","timestamp":1417235590486,"duration":0,"exception":"javax.ws.rs.WebApplicationException"}
你能解释一下我错在哪里吗?我错过了什么吗?
答案 0 :(得分:0)
你真的在那里用星号打电话吗?你需要在那里提供一个设备uuid。
此外,它使用JSON,因此您需要将JSON对象POST到/notifications
端点。类似的东西:
$payload = array(
"payloads" => array(
"apple" => array(
"aps" => array(
"alert":"Your message here."
)
)
)
);
$send = json_encode($payload);