protected function parseResponse(TranslationQueryResponse $reply)
 {
     $body = $reply->getBody();
     $response = FormatJson::decode($body);
     if (!is_object($response)) {
         throw new TranslationWebServiceException('Invalid json: ' . serialize($body));
     }
     $text = preg_replace('~^<div>(.*)</div>$~', '\\1', $response->contents);
     $text = $this->unwrapUntranslatable($text);
     return trim($text);
 }
 protected function parseResponse(TranslationQueryResponse $reply)
 {
     $body = $reply->getBody();
     $parsed = FormatJson::decode($body, true);
     if (!is_array($parsed)) {
         throw new TranslationWebServiceException('Invalid json: ' . serialize($body));
     }
     if (!isset($parsed['ttmserver'])) {
         throw new TranslationWebServiceException('Unexpected reply from remote server');
     }
     return $parsed['ttmserver'];
 }
 protected function parseResponse(TranslationQueryResponse $reply)
 {
     $body = $reply->getBody();
     $response = FormatJson::decode($body);
     if (!is_object($response)) {
         throw new TranslationWebServiceException('Invalid json: ' . serialize($body));
     } elseif ($response->code !== 200) {
         throw new TranslationWebServiceException($response->message);
     }
     $text = Sanitizer::decodeCharReferences($response->text[0]);
     $text = $this->unwrapUntranslatable($text);
     return trim($text);
 }
 /**
  * Returns a response for a query.
  * @param mixed $id Query id.
  * @return TranslationQueryResponse
  * @throws RuntimeException if called before run() has been called.
  */
 public function getResponse($id)
 {
     if (!$this->hasRun) {
         throw new RuntimeException('Tried to get response before queries ran');
     }
     return TranslationQueryResponse::newFromMultiHttp($this->responses[$id]);
 }
 /**
  * Get the web service specific response returned by QueryAggregator.
  *
  * @param TranslationQueryResponse $response
  * @return mixed
  * @since 2015.12
  */
 public function getResultData(TranslationQueryResponse $response)
 {
     if ($response->getStatusCode() !== 200) {
         $this->reportTranslationServiceFailure($response->getStatusMessage());
         return array();
     }
     try {
         return $this->parseResponse($response);
     } catch (Exception $e) {
         $this->reportTranslationServiceFailure($e->getMessage());
         return array();
     }
 }
 protected function parseResponse(TranslationQueryResponse $reply)
 {
     $body = $reply->getBody();
     $text = preg_replace('~<string.*>(.*)</string>~', '\\1', $body);
     $text = Sanitizer::decodeCharReferences($text);
     $text = $this->unwrapUntranslatable($text);
     return $text;
 }
 protected function parseResponse(TranslationQueryResponse $reply)
 {
     $xml = simplexml_load_string($reply->getBody());
     $text = Sanitizer::decodeCharReferences($xml->translation->paragraph);
     $text = $this->unwrapUntranslatable($text);
     return $text;
 }