コード例 #1
0
 /**
  * Sendet den übergebenen Request zum Server und gibt das Result zurück
  * @param Dragon_Json_Server_Request_Http $request
  * @return array
  */
 public function send(Dragon_Json_Server_Request_Http $request)
 {
     $request->addParam(-1, 'timestamp');
     $body = $this->_httpclient->setRawData($request->toJson())->request('POST')->getBody();
     try {
         $response = Zend_Json::decode($body);
     } catch (Exception $exception) {
         throw new Dragon_Application_Exception_System('decoding failed', array('message' => $exception->getMessage(), 'body' => $body));
     }
     if (!is_array($response) || !array_key_exists('id', $response)) {
         throw new Dragon_Application_Exception_System('invalid response', array('response' => $response, 'body' => $body));
     }
     if (array_key_exists('error', $response)) {
         throw new Dragon_Application_Exception_System($response['error']['message'], array('error' => $response['error']));
     }
     if (!array_key_exists('result', $response)) {
         throw new Dragon_Application_Exception_System('invalid response', array('response' => $response, 'body' => $body));
     }
     return $response['result'];
 }