コード例 #1
0
 protected function httpGet($uri)
 {
     $results = [];
     // Start requesting at page 1
     $page = 1;
     // We dont know how many pages there are, so assume 1 until we know
     $pagecount = 1;
     while ($page <= $pagecount) {
         $this->log[] = ['request' => ['method' => 'GET', 'uri' => $uri . '?page=' . $page]];
         $response = \Httpful\Request::get($uri . '?page=' . $page)->addHeader('X-Auth-Email', $this->email)->addHeader('X-Auth-Key', $this->apikey)->expectsType(\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("get {$uri} unsuccessful" . \Metaclassing\Utility::encodeJson($response));
         }
         foreach ($response['result'] as $result) {
             array_push($results, $result);
         }
         // Now that we KNOW the pagecount, update that and increment our page counter
         $pagecount = $response['result_info']['total_pages'];
         // And get the next page ready for the next request
         $page++;
     }
     return $results;
 }
コード例 #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
ファイル: Netman.php プロジェクト: metaclassing/utility
 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);
 }