Page 1 of 2

Push notification REST service (using cURL and PHP) suddenly started timing out?

Posted: Fri Nov 08, 2013 5:42 am
by Nathanael

Recently, the Push notification REST service we have implemented on our website (using cURL) has started timing out. Upon looking at the documentation, I realized the entire REST service parameter formats have changed!

Here is my current script, just for a quick reference:

precode$data = array(
'channels' => array($push_channel_id),
'message' => $message,
'deviceID' => $device->device_id
);

$data_string = json_encode($data);

$ch = curl_init('https://api.appery.io/rest/push/msg');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-Appery-Push-Master-Key:' . $push_master_key,
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string)
));
curl_exec($ch);/code/pre


Push notification REST service (using cURL and PHP) suddenly started timing out?

Posted: Fri Nov 08, 2013 6:25 am
by Oleg Danchenkov

Hi, Nathanael.
We have new Push API. Please check http://docs.appery.io/documentation/p...
But old API is still in use. Probably your X-Appery-Push-Master-Key has been changed. Please check it (see http://docs.appery.io/documentation/b...)


Push notification REST service (using cURL and PHP) suddenly started timing out?

Posted: Fri Nov 08, 2013 6:57 pm
by Nathanael

Hello!

I have confirmed my master key is correct. Here is the JSON I am sending:

{"payload":{"message":"This is a test notification!"},"filter":{"deviceID":"99000120142526;28e176fa3f4850b3"}}

Is there something incorrect here? The new documentation is extremely vague, so I have absolutely no idea if this is correct. However, I am not receiving any error messages, so I presume it is correct...?

Unless, is this an error message?

{"code":"PNMN101","description":"Empty scheduled time"}

If it is, it is not listed in the documentation.


Push notification REST service (using cURL and PHP) suddenly started timing out?

Posted: Fri Nov 08, 2013 10:29 pm
by Kateryna Grynko

Hi Nathanael,

Please check if there are any errors if you specify scheduled time.


Push notification REST service (using cURL and PHP) suddenly started timing out?

Posted: Fri Nov 08, 2013 11:53 pm
by Nathanael

I received a "serialization error". I'm assuming that means the date was formatted incorrectly. The documentation does not provide any explanation of what kind of parameters are expected.

However, more importantly, the script keeps timing out, even when the Push notification successfully sends. I managed to get it working by adding "status: sent" but I am still not hearing a response from the server.

The fact that I am receiving the notification means that the server is indeed receiving my request, meaning that the problem is on your side, not mine.


Push notification REST service (using cURL and PHP) suddenly started timing out?

Posted: Mon Nov 11, 2013 9:30 am
by Kateryna Grynko

Hi Nathanael,

Sorry for the delay. We can't reproduce this behaviour. Could you please share the script?


Push notification REST service (using cURL and PHP) suddenly started timing out?

Posted: Mon Nov 11, 2013 5:40 pm
by Nathanael

The following is the part of the script that is freezing up:

precode$data = array(
'filter' => array('deviceID' => $device->device_id),
'payload' => array('message' => $message),
'status' => 'sent',
);

$data_string = json_encode($data);

$ch = curl_init('https://api.appery.io/rest/push/msg');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-Appery-Push-Master-Key:' . $push_master_key,
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string)
));
echo curl_exec($ch);/code/pre

$device-device_id
99000120142526;28e176fa3f4850b3

$message
This is a test notification!

$push_master_key
My (confirmed correct) master key.

As it stands, I receive the notification, but never receive a response. That means the script holds up, and I am unable to loop through any other devices that should also be receiving the notification. Only the first gets the notification, meaning that your servers are indeed receiving my request.

Let me know what you find!


Push notification REST service (using cURL and PHP) suddenly started timing out?

Posted: Tue Nov 12, 2013 3:08 pm
by Kateryna Grynko

Hi Nathanael,

This should help you:
http://docs.appery.io/documentation/b...


Push notification REST service (using cURL and PHP) suddenly started timing out?

Posted: Tue Nov 12, 2013 6:49 pm
by Nathanael

I have already looked there, over and over again. The issue is not that the push notification is not sending—it is.

The problem is that https://api.appery.io/rest/push/msg is not returning a response. Perhaps my request is malformed, but considering the notification is, indeed, being sent... that doesn't make sense. And even if my request is bad, I should still be receiving an error response.

I am not receiving emany/em response.


Push notification REST service (using cURL and PHP) suddenly started timing out?

Posted: Wed Nov 13, 2013 11:47 am
by Kateryna Grynko

Hi Nathanael,

You code doesn't include SSL support. Please use the following code that returns server response:
pre$url = "https://api.appery.io/rest/push/msg";
$message = '{"payload":{"message":"1111","badge":"1"},"status":"sent"}';
$headers = array(
'X-Appery-Push-Master-Key: XXXXXXXX',
'Content-type: application/json'
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $message);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
$result = curl_exec($ch);

print_r($result);/pre