Пример #1
0
 public function search($query)
 {
     // Translate the search array into JSON
     $json = \Metaclassing\Utility::encodeJson($query);
     // Post the JSON
     $response = $this->post($this->baseurl . '/information/api/search/', $this->baseurl, $json);
     // return an assoc array with results
     return \Metaclassing\Utility::decodeJson($response);
 }
Пример #2
0
 protected function soapCall($action, $parameters = null)
 {
     // deep black magic
     $response = $this->soap->{$action}($parameters);
     $response = \Metaclassing\Utility::encodeJson($response);
     $response = \Metaclassing\Utility::decodeJson($response);
     $this->log[] = ['request' => ['action' => $action, 'parameters' => $parameters], 'response' => ['response' => $response]];
     return $response;
 }
Пример #3
0
 public function getjson($url, $referer = '')
 {
     if ($this->token) {
         $url .= '?token=' . $this->token;
     }
     curl_setopt($this->curl, CURLOPT_URL, $url);
     curl_setopt($this->curl, CURLOPT_REFERER, $referer);
     $response = $this->curl_exec();
     if (!\Metaclassing\Utility::isJson($response)) {
         throw new \Exception('Did not get JSON response from web service url ' . $url . ', got ' . $response);
     }
     $response = \Metaclassing\Utility::decodeJson($response);
     if (isset($response['status_code']) && $response['status_code'] != 200) {
         throw new \Exception('Did not get a 200 response from web service for last call,' . ' url was ' . $url . ' response was ' . \Metaclassing\Utility::dumperToString($response));
     }
     return $response;
 }
Пример #4
0
 protected function httpDelete($uri)
 {
     $this->log[] = ['request' => ['method' => 'DELETE', 'uri' => $uri]];
     $response = \Httpful\Request::delete($uri)->addHeader('X-Auth-Email', $this->email)->addHeader('X-Auth-Key', $this->apikey)->expects(\Httpful\Mime::JSON)->parseWith(function ($body) {
         return \Metaclassing\Utility::decodeJson($body);
     })->send()->body;
     $this->log[count($this->log) - 1]['response'] = $response;
     if ($response['success'] != true) {
         throw new \Exception("delete to {$uri} unsuccessful");
     }
     return $response['result'];
 }