Ejemplo n.º 1
0
 public function getjson($url, $referer = '')
 {
     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);
     //\Metaclassing\Utility::dumper($response);
     return $response;
 }
Ejemplo n.º 2
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;
 }