2011-08-19 184 views
3

我使用此代码来推动:推送通知iPhone

push("xxxx", 3); 

function push($deviceToken, $badge) { 

    $message = "C'è il vento ideale!!"; 
    $sound = "default"; 

    // Construct the notification payload 
    $body = array(); 
    $body['aps'] = array(
     "alert" => $message 
    ); 

    if ($badge) { 
     $body['aps']['badge'] = $badge; 
    } 

    if ($sound) { 
     $body['aps']['sound'] = $sound; 
    } 

    $ctx = stream_context_create(); 
    stream_context_set_option($ctx, 'ssl', 'local_cert', 'apns-dev.pem'); 
    $fp = stream_socket_client("ssl://gateway.sandbox.push.apple.com:2195", $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx); 

    if (!$fp) { 
    print "Failed to connect $err $errstrn"; 
     return; 
    } else { 
     print "Connection OK\n"; 
    } 

    $payload = json_encode($body); 
    $msg = chr(0) . pack('n', 32) . pack('H*', str_replace(' ', '', $deviceToken)) . pack('n', strlen($payload)) . $payload; 
    print "sending message :" . $payload . "\n"; 
    fwrite($fp, $msg); 
    fclose($fp); 
} 

但是,这是错误:

Warning: stream_socket_client() [function.stream-socket-client]: SSL operation failed with code 1. OpenSSL Error messages: error:14094414:SSL routines:SSL3_READ_BYTES:sslv3 alert certificate revoked in /xxxx/notify.php on line 75

Warning: stream_socket_client() [function.stream-socket-client]: Failed to enable crypto in /xxxx/notify.php on line 75

Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.sandbox.push.apple.com:2196 (Unknown error) in /xxxxx/notify.php on line 75 Failed to connect 0

+0

它看起来像你的证书不再有效。 –

回答

2

的信息是明确的:certificate revoked
您的证书无效,证书已过期,或者您已在Apple门户中单击“撤消”该证书。

您可以为此appId生成一个新证书,并将其安装到您的服务器上。