/** * Handles an HTTP response. * * @param org_tubepress_api_http_HttpResponse $response The HTTP response. * * @throws Exception If something goes wrong. * * @return string The raw entity body of the response. May be empty or null. */ function handle(org_tubepress_api_http_HttpResponse $response) { $statusCode = $response->getStatusCode(); org_tubepress_impl_log_Log::log(self::$_logPrefix, 'Response returned status %d', $statusCode); switch ($statusCode) { case 200: return $this->_handleSuccess($response); default: return $this->_handleError($response); } }
/** * Get a user-friendly response message for this HTTP response. * * @param org_tubepress_api_http_HttpResponse $response The HTTP response. * * @return string A user-friendly response message for this HTTP response. */ protected function getMessageForResponse(org_tubepress_api_http_HttpResponse $response) { switch ($response->getStatusCode()) { case 401: return 'YouTube didn\'t authorize this request due to a missing or invalid Authorization header.'; case 403: return 'YouTube determined that the request did not contain proper authentication.'; case 500: return 'YouTube experienced an internal error while handling this request. Please try again later.'; case 501: return 'The YouTube API does not implement the requested operation.'; case 503: return 'YouTube\'s API cannot be reached at this time (likely due to overload or maintenance). Please try again later.'; default: return $this->_parseError($response); } }