public final function onResponse(ehough_tickertape_GenericEvent $event)
 {
     /**
      * @var $request ehough_shortstop_api_HttpRequest
      */
     $request = $event->getArgument('request');
     /**
      * @var $response ehough_shortstop_api_HttpResponse
      */
     $response = $event->getSubject();
     if (!$this->_canHandle($request, $response)) {
         //this is not a Vimeo response
         return;
     }
     switch ($response->getStatusCode()) {
         case 200:
             return;
         default:
             $toReturn = 'Vimeo responded to TubePress with an HTTP ' . $response->getStatusCode();
             break;
     }
     $parsedError = $this->_parseError($response);
     if ($parsedError) {
         $toReturn .= ' - ' . $parsedError;
     }
     throw new ehough_shortstop_api_exception_RuntimeException($toReturn);
 }
 /**
  * Sets some default headers on the request.
  *
  * @param ehough_tickertape_GenericEvent $event The pre-request event.
  *
  * @return void
  */
 public function onPreRequest(ehough_tickertape_GenericEvent $event)
 {
     $request = $event->getSubject();
     $this->_isDebugEnabled = $this->_logger->isHandling(ehough_epilog_Logger::DEBUG);
     $this->_setDefaultHeadersBasic($request);
     $this->_setDefaultHeadersCompression($request);
     $this->_setDefaultHeadersContent($request);
 }
 /**
  * Sets some default headers on the request.
  *
  * @param ehough_tickertape_GenericEvent $event The pre-request event.
  *
  * @return void
  */
 public function onPreRequest(ehough_tickertape_GenericEvent $event)
 {
     $request = $event->getSubject();
     if ($this->_logger->isHandling(ehough_epilog_Logger::DEBUG)) {
         $this->_logger->debug(sprintf('Will attempt %s', $request));
         $this->_logRequest($request);
     }
 }
 public function onResponse(ehough_tickertape_GenericEvent $event)
 {
     if (!$this->_logger->isHandling(ehough_epilog_Logger::DEBUG)) {
         return;
     }
     $response = $event->getSubject();
     $request = $event->getArgument('request');
     $this->_logger->debug(sprintf('The raw result for %s is in the HTML source for this page <span style="display:none">%s</span>', $request, htmlspecialchars(var_export($response, true))));
 }
 public final function onRequest(ehough_tickertape_GenericEvent $event)
 {
     /**
      * @var $request ehough_shortstop_api_HttpRequest
      */
     $request = $event->getSubject();
     if ($request->getUrl()->getHost() !== 'vimeo.com') {
         //not a Vimeo request
         return;
     }
     $clientId = $this->_executionContext->get(tubepress_addons_vimeo_api_const_options_names_Feed::VIMEO_KEY);
     $clientSecret = $this->_executionContext->get(tubepress_addons_vimeo_api_const_options_names_Feed::VIMEO_SECRET);
     $clientCredentials = new ehough_coauthor_api_v1_Credentials($clientId, $clientSecret);
     $this->_oauthClient->signRequest($request, $clientCredentials);
 }
 public final function onResponse(ehough_tickertape_GenericEvent $event)
 {
     /**
      * @var $request ehough_shortstop_api_HttpRequest
      */
     $request = $event->getArgument('request');
     /**
      * @var $response ehough_shortstop_api_HttpResponse
      */
     $response = $event->getSubject();
     if (!$this->_canHandle($request, $response)) {
         //this is not a YouTube response
         return;
     }
     switch ($response->getStatusCode()) {
         case 200:
             return;
         case 400:
             $toReturn = 'YouTube didn\'t like something about TubePress\'s request.';
             break;
         case 401:
             $toReturn = 'YouTube didn\'t authorize TubePress\'s request.';
             break;
         case 403:
             $toReturn = 'YouTube determined that TubePress\'s request did not contain proper authentication.';
             break;
         case 500:
             $toReturn = 'YouTube experienced an internal error while handling TubePress\'s request. Please try again later.';
             break;
         case 501:
             $toReturn = 'The YouTube API does not implement the requested operation.';
             break;
         case 503:
             $toReturn = 'YouTube\'s API cannot be reached at this time (likely due to overload or maintenance). Please try again later.';
             break;
         default:
             $toReturn = 'YouTube responded to TubePress with an HTTP ' . $response->getStatusCode();
             break;
     }
     $parsedError = $this->_parseError($response);
     if ($parsedError) {
         $toReturn .= ' - ' . $parsedError;
     }
     throw new ehough_shortstop_api_exception_RuntimeException($toReturn);
 }
 public function onResponse(ehough_tickertape_GenericEvent $event)
 {
     $isDebugEnabled = $this->_logger->isHandling(ehough_epilog_Logger::DEBUG);
     $response = $event->getSubject();
     if ($this->_responseDecoder->needsToBeDecoded($response)) {
         if ($isDebugEnabled) {
             $this->_logger->debug(sprintf('Response is %s-Encoded. Attempting decode.', $this->_name));
         }
         $this->_responseDecoder->decode($response);
         if ($isDebugEnabled) {
             $this->_logger->debug(sprintf('Successfully decoded %s-Encoded response.', $this->_name));
         }
     } else {
         if ($isDebugEnabled) {
             $this->_logger->debug(sprintf('Response is not %s-Encoded.', $this->_name));
         }
     }
 }