// connect to Redis server $redis = new Predis\Client('tcp://127.0.0.1:6379'); // Redis queue key $QUEUE_KEY = 'list.apns.messagequeue'; // enable log $_ENABLE_LOG = true; // path to log $LOGPATH = '/path/to/logs/'; // Using Autoload all classes are loaded on-demand require_once '/path/to/ApnsPHP/Autoload.php'; // Instanciate a new ApnsPHP_Push object $server = new ApnsPHP_Push_Server(ApnsPHP_Abstract::ENVIRONMENT_SANDBOX, '/path/to/apns.pem'); // Set the Root Certificate Autority to verify the Apple remote peer $server->setRootCertificationAuthority('/path/to/entrust_root_certification_authority.pem'); // Set the number of concurrent processes $server->setProcesses(4); // Starts the server forking the new processes $server->start(); _pushLog(array(date('Y-m-d H:i:s'), 'STARTING SERVER')); /* * Main server run loop */ while ($server->run()) { $date = date('Y-m-d H:i:s'); // Check the error queue $aErrorQueue = $server->getErrors(); if (!empty($aErrorQueue)) { var_dump($aErrorQueue); } // get latest queue list($deviceToken, $badgeNum, $text) = popQueue();
* * @author (C) 2010 Aldo Armiento (aldo.armiento@gmail.com) * @version $Id: sample_server.php 55 2010-08-27 19:07:38Z aldo.armiento $ */ // Adjust to your timezone date_default_timezone_set('Europe/Rome'); // Report all PHP errors error_reporting(-1); // Using Autoload all classes are loaded on-demand require_once 'ApnsPHP/Autoload.php'; // Instanciate a new ApnsPHP_Push object $server = new ApnsPHP_Push_Server(ApnsPHP_Abstract::ENVIRONMENT_SANDBOX, 'server_cerificates_bundle_sandbox.pem'); // Set the Root Certificate Autority to verify the Apple remote peer $server->setRootCertificationAuthority('entrust_root_certification_authority.pem'); // Set the number of concurrent processes $server->setProcesses(2); // Starts the server forking the new processes $server->start(); // Main loop... $i = 1; while ($server->run()) { // Check the error queue $aErrorQueue = $server->getErrors(); if (!empty($aErrorQueue)) { // Do somethings with this error messages... var_dump($aErrorQueue); } // Send 10 messages if ($i <= 10) { // Instantiate a new Message with a single recipient $message = new ApnsPHP_Message('1e82db91c7ceddd72bf33d74ae052ac9c84a065b35148ac401388843106a7485');