'json', 'action' => 'ttmserver', 'sourcelanguage' => $from, 'targetlanguage' => $to, 'text' => $text ]; if ( isset( $this->config['service'] ) ) { $params['service'] = $this->config['service']; } return TranslationQuery::factory( $this->config['url'] ) ->timeout( $this->config['timeout'] ) ->queryParameters( $params ); } 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']; } }