推送通知结果87

时间:2011-11-16 10:02:48

标签: iphone objective-c push-notification apple-push-notifications

我在php中发送推送通知我在结果变量中得到了“87”。它意味着什么。

    <?php
    $deviceToken = "a448b8946a5de3801dc6a11862a5a0bf11f1adc16xxxxxxxxxxxx"; // masked for security reason
    // Passphrase for the private key
    $pass = 'molik';

    // Get the parameters from http get or from command line
    $message = $_GET['message'] or $message = $argv[1] or $message = 'Test Message';
    //$badge = (int)$_GET['badge'] or $badge = (int)$argv[2] or $badge  = 1;
    $sound = $_GET['sound'] or $sound = $argv[3] or $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;


    /* End of Configurable Items */
    $ctx = stream_context_create();
    stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');
    // assume the private key passphase was removed.
    stream_context_set_option($ctx, 'ssl', 'passphrase', $pass);

    // for production change the server to ssl://gateway.push.apple.com:219
    $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 $errstr\n";
        return;
    }
    else {
        print "Connection OK\n";
    }

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

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

     echo ">>" .$result ."<<" . PHP_EOL;
     fclose($fp);

输出

 Connection OK
 sending message :{"aps":{"alert":"Test Message","sound":"default"}}
 >>87<<

1 个答案:

答案 0 :(得分:1)

在PHP中fwrite返回写入的字符数,在这种情况下是写入套接字的字节数。