2011-08-19 183 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生成一個新證書,並將其安裝到您的服務器上。