Error when sending notification by apigee

98 views Asked by At

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?

1

There are 1 answers

2
brandonscript On

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