Пример #1
0
 public function indexAction()
 {
     $this->_helper->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     $storage = new Zend_Feed_Pubsubhubbub_Storage_Filesystem();
     $storage->setDirectory(APPLICATION_ROOT . '/store/subscriptions');
     $callback = new Zend_Feed_Pubsubhubbub_Subscriber_Callback();
     $callback->setStorage($storage);
     /**
      * At time of writing, no fully PuSH 0.2 compatible Hubs exist
      * so we must detect the expected verify token (if used) and set
      * it explicitly. This is used by all callback requests and is set
      * when subscribing.
      */
     $callback->setVerifyToken($this->_getParam('subkey'));
     $callback->handle();
     /**
      * Check if a feed update was received and process it
      * asynchronously. Note: Asynchronous processing should be
      * utilised since a Hub might timeout very quickly if the
      * processing time exceeds its timeout setting (including
      * network latency).
      */
     if ($callback->hasFeedUpdate()) {
         $data = $callback->getFeedUpdate();
         $key = md5($data);
         file_put_contents(APPLICATION_ROOT . '/store/updates/' . $key, $data);
         $this->_helper->getHelper('Spawn')->setScriptPath(APPLICATION_ROOT . '/scripts/zfrun.php');
         $this->_helper->spawn(array('--key' => $key), 'process', 'callback');
     }
     file_put_contents(APPLICATION_ROOT . '/log/' . microtime(true), print_r($callback->getHttpResponse(), true));
     /**
      * Send final response to Client
      */
     $callback->sendResponse();
 }