ApnsFeedback.php 609 B

123456789101112131415161718192021
  1. <?php
  2. require_once 'Zend/Mobile/Push/Apns.php';
  3. $apns = new Zend_Mobile_Push_Apns();
  4. $apns->setCertificate('/path/to/provisioning-certificate.pem');
  5. try {
  6. $apns->connect(Zend_Mobile_Push_Apns::SERVER_FEEDBACK_SANDBOX_URI);
  7. } catch (Zend_Mobile_Push_Exception_ServerUnavailable $e) {
  8. // you can either attempt to reconnect here or try again later
  9. exit(1);
  10. } catch (Zend_Mobile_Push_Exception $e) {
  11. echo 'APNS Connection Error:' . $e->getMessage();
  12. exit(1);
  13. }
  14. $tokens = $apns->feedback();
  15. foreach ($tokens as $token => $time) {
  16. echo $time . "\t" . $token . PHP_EOL;
  17. }
  18. $apns->close();