Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

push notification issue

Links for php scripts

Moderators: macek, egami, gesf

push notification issue

Postby 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
User avatar
santoshkumar
New php-forum User
New php-forum User
 
Posts: 5
Joined: Thu Apr 10, 2014 6:20 am
Location: Hyderabad, India

Re: push notification issue

Postby seandisanti » 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
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: push notification issue

Postby 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 ?
User avatar
santoshkumar
New php-forum User
New php-forum User
 
Posts: 5
Joined: Thu Apr 10, 2014 6:20 am
Location: Hyderabad, India

Re: push notification issue

Postby seandisanti » 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
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: push notification issue

Postby 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?
User avatar
santoshkumar
New php-forum User
New php-forum User
 
Posts: 5
Joined: Thu Apr 10, 2014 6:20 am
Location: Hyderabad, India

PDF compress Query

Postby santoshkumar » Tue Apr 15, 2014 3:55 pm

Hi, how to compres pdfs in php
User avatar
santoshkumar
New php-forum User
New php-forum User
 
Posts: 5
Joined: Thu Apr 10, 2014 6:20 am
Location: Hyderabad, India

Re: push notification issue

Postby seandisanti » 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
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm


Return to PHP Scripts

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.