private function _doParseError(ehough_shortstop_api_HttpResponse $response) { $entity = $response->getEntity(); $rawResponse = $entity->getContent(); $unserialized = @unserialize($rawResponse); return $unserialized->err->msg; }
/** * Determines if this response needs to be decoded. * * @param ehough_shortstop_api_HttpResponse $response The HTTP response. * * @return boolean True if this response should be decoded. False otherwise. */ public final function needsToBeDecoded(ehough_shortstop_api_HttpResponse $response) { $entity = $response->getEntity(); $isDebugEnabled = $this->_logger->isHandling(ehough_epilog_Logger::DEBUG); if ($entity === null) { if ($isDebugEnabled) { $this->_logger->debug('Response contains no entity'); } return false; } $content = $entity->getContent(); if ($content == '' || $content == null) { if ($isDebugEnabled) { $this->_logger->debug('Response entity contains no content'); } return false; } $expectedHeaderName = $this->getHeaderName(); $actualHeaderValue = $response->getHeaderValue($expectedHeaderName); if ($actualHeaderValue === null) { if ($isDebugEnabled) { $this->_logger->debug(sprintf('Response does not contain %s header. No need to decode.', $expectedHeaderName)); } return false; } if ($isDebugEnabled) { $this->_logger->debug(sprintf('Response contains %s header. Will attempt decode.', $expectedHeaderName)); } return true; }
private function _doParseError(ehough_shortstop_api_HttpResponse $response) { $entity = $response->getEntity(); $rawResponse = $entity->getContent(); $domDocument = new DOMDocument(); $domDocument->loadXML($rawResponse); $xpath = new DOMXPath($domDocument); $xpath->registerNamespace('google', 'http://schemas.google.com/g/2005'); return $xpath->query('//google:error[1]/google:internalReason')->item(0)->nodeValue; }