English 中文(简体)
Feedback service for Push notification
原标题:

I wrote the below script to read the feedback data. But, for some reasons, I am not receiving any data from the server. Can you kindly let me know whats wrong with the script. Also, if you have any working php script for feedback service, can you kindly share it...

regards, DD.

 <?php

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


// Set time limit to indefinite execution
set_time_limit (0); 

// Set the ip and port we will listen on
$address =  ssl://feedback.sandbox.push.apple.com ;
$port = 2196; 

// Create a TCP Stream socket
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
echo "PHP Socket Server started at " . $address . " " . $port . "
";

// Bind the socket to an address/port
socket_bind($sock, $address, $port) or die( Could not bind to address );
// Start listening for connections
socket_listen($sock); 

//loop and listen

while (true) {
    /* Accept incoming requests and handle them as child processes */
    $client = socket_accept($sock); 

    // Read the input from the client – 1024 bytes
    $input = socket_read($client, 1024); 


}

// Close the client (child) socket
socket_close($client); 

// Close the master sockets
socket_close($sock);

?>
问题回答

You must act as a client, just like you re sending notification. That must be something like:

<?php
$certFile =  apns-dev.pem ;

while (true) { 
    $ctx = stream_context_create(); 
    stream_context_set_option($ctx,  ssl ,  local_cert , $certFile); 
    //stream_context_set_option($ctx,  ssl ,  passphrase , $this->certPass);
    echo "try to open stream
";
    $fp = stream_socket_client( ssl://feedback.sandbox.push.apple.com:2196 , $err, $errstr, 5, STREAM_CLIENT_CONNECT, $ctx); 
    if (!$fp) { 
      print "Failed to connect". $err . $errstr. "
"; 
      exit(); 
    } else {
        echo  Connected to feedback sandbox... ;
        while (($in = fread($fp, 1024)) != EOF) {
            echo  read  . $in . "
";   
        }

        socket_close($fp);
        fclose($fp);
    }
    sleep(2000);
}
?>




相关问题
Alert email in TFS and power tools

I have a problem with TFS and email notifications. I can not receive any emails from TFS server for work item tracking. I correctly have configured web.config in ...Web ServicesServices in TFS ...

3 notifications instead of one

I m developing simple MVC app in Cocoa/Objective-C. I have a strange issue (or misunderstanding) with notifications and KVO. I have AppController object in MainMenu.xib, hence I implement ...

Notification when laptop is switch on (boot)

I need to know, is that possible to get a notification through email whenever my laptop is switched on or is connected to internet ? An alternative is to get notification when set service Starts on ...

Feedback service for Push notification

I wrote the below script to read the feedback data. But, for some reasons, I am not receiving any data from the server. Can you kindly let me know whats wrong with the script. Also, if you have any ...

热门标签