push notification issue

Links for php scripts

Moderators: egami, macek, gesf

Post Reply
santoshkumar

Thu Apr 10, 2014 6:27 am

hai , iam santosh i have a one problem with push notifications, iam develop the code for push notifications
but in the godaddy hosting server it shows Failed to connect 111 Conections refused. please help me

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Thu Apr 10, 2014 4:39 pm

The error seems pretty straightforward, connection was refused. For more specific help, you will need to show some code for us to diagnose. Make sure you replace sensitive connection values (credentials etc) before posting code

santoshkumar

Fri Apr 11, 2014 1:29 am

i wrote this code


$message="hai this is for testing";
$deviceToken=$row['device_token'];


$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', 'welcome');

// Open a connection to the APNS server $passphrase
$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);

if (!$fp)


exit("Failed to connect: $err $errstr" . PHP_EOL);


//echo 'Connected to APNS' . PHP_EOL;

// Create the payload body
$body['aps'] = array(
'alert' => $message,
'sound' => 'default',
'badge' => '1',
'type' => 'notification'
);

// Encode the payload as JSON
$payload = json_encode($body);

// Build the binary notification
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;

// Send it to the server

$result = fwrite($fp, $msg, strlen($msg));


if (!$result)
echo 'Message not delivered' . PHP_EOL;
else
echo 'Message successfully delivered' . PHP_EOL;




// Close the connection to the server
fclose($fp);



in this i have an r=error in godaddy Failed to connect: 111 Connection refused.

can we need any ssl certificates for godaddy ?

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Fri Apr 11, 2014 8:14 am

Here's some code for opening SSL stream:
http://www.php.net/manual/en/function.s ... .php#85345

santoshkumar

Fri Apr 11, 2014 10:57 pm

same code run in my local wamp server its working fine. but in godaddy server host its problem, is it any problem with firewalls?

santoshkumar

Tue Apr 15, 2014 3:55 pm

Hi, how to compres pdfs in php

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Wed Apr 16, 2014 1:14 am

Yes, godaddy can be blocking ports that would cause the issues you're having. http://lmgtfy.com/?q=write+pdf+with+php

Post Reply