Apple Push Notification GERİ hizmet için PHP komut dosyası, zaman aşımı her zaman alır

0 Cevap php

Greetings everyone! I'm currently implementing the Feedback service for Apples Push notifications. I've got the pushing part all done and working both on sandbox and on distribution apps. However the feedback service seems to not work.. Each time i try to use my function.. the page well.. just gets a timeout.

Benim işlevi yapmak için bu cevabı izledi: PHP technique to query the APNs Feedback Server

İşte benim tam fonksiyon kodu:

function checkFeedbackServer($appBundle,$useDev = TRUE)
{
    $apnsPort = 2195;
    $apnsCert = keyForApp($appBundle,$useDev);

    if($useDev)
    {
        echo 'FEEDBACK in DEVELOPER MODE <br/>';
        $apnsHost = 'feedback.sandbox.push.apple.com';
    }
    else
    {
        echo 'FEEDBACK in DISTRIBUTION MODE <br/>';
        $apnsHost = 'feedback.push.apple.com';
    }
    $finalPath = 'ssl://' . $apnsHost . ':' . $apnsPort;

    echo 'OPENING STREAM TO -> ' . $finalPath . '<br/>';
    echo 'USING CERT : ' . $apnsCert . "<br/>";


    $stream_context = stream_context_create();
    stream_context_set_option($stream_context, 'ssl', 'local_cert', $apnsCert);

    $apns = stream_socket_client($finalPath, $error, $errorString, 2, STREAM_CLIENT_CONNECT, $stream_context);

    if(!$apns) 
    {
        echo "ERROR $errcode: $errstr\n";
        return;
    }
    else echo 'APNS FEEDBACK CONNECTION ESTABLISHED...<br/>';

    $feedback_tokens = array();    
    $count = 0;

    echo 'error= ' . $error . '<br/>';
    echo 'errorString= ' . $errorString . '<br/>';

    if(!feof($apns))
        echo 'APNS NOT FINISHED <br/>';
    else
        echo 'APNS FINISHED? <br/>';    

    $result = fread($apns, 38);
    echo 'result= ' . $result;
    fclose($apns);
}

Fark ettim ki ben satırları kaldırırsanız:

$result = fread($apns, 38);
echo 'result= ' . $result;

Işlevi sonra düzgün çalışır. Yani nuthsell ben geribildirim hizmet üretim ve geliştirici hem de bir bağlantı açmak mümkün ama en kısa sürede benim komut dosyası sadece zaman aşımına sunucudan herhangi bir veri elde etmeye çalışmak gibi ..

Ayrıca fonksiyon keyForApp($appBundle,$useDev) doğru sertifika getirir benim veritabanına bir sorgu etrafında sadece basit bir sarıcı. Ben cihaza mesaj iterken ben de onu kullanıyorum beri çalışıyor guarante.

0 Cevap