Nathanael
Posts: 0
Joined: Tue Dec 11, 2012 11:25 pm

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

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

Oleg Danchenkov
Posts: 0
Joined: Tue Apr 30, 2013 5:51 pm

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

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

Nathanael
Posts: 0
Joined: Tue Dec 11, 2012 11:25 pm

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

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.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

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

Hi Nathanael,

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

Nathanael
Posts: 0
Joined: Tue Dec 11, 2012 11:25 pm

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

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.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

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

Hi Nathanael,

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

Nathanael
Posts: 0
Joined: Tue Dec 11, 2012 11:25 pm

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

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!

Nathanael
Posts: 0
Joined: Tue Dec 11, 2012 11:25 pm

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

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.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

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

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

Return to “Issues”