简体   繁体   中英

Error when sending notification by apigee

I created a php file to send an example notification to my devices:

<?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;
?>

But when I run it, i received this error message:

{"error":"web_application","timestamp":1417235590486,"duration":0,"exception":"javax.ws.rs.WebApplicationException"}

May you explain where was I wrong? Did I miss something?

Are you actually calling it with the asterisk in there? You need to provide a device uuid there.

Also, it consumes JSON, so you'll need to POST a JSON object to the /notifications endpoint. Something like:

$payload = array(
              "payloads" => array(
                  "apple" => array(
                      "aps" => array(
                          "alert":"Your message here."
                       )
                   )
               )
           );

$send = json_encode($payload);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM