/** * Perform at GET request against the API * * @throws Exception on HTTP or Json decode error * @param string $url * @return array */ public function get($url) { $getUrl = $this->apiUrl . '/' . ltrim($url, '/'); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $getUrl); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_USERAGENT, OpenVBX::getVbxUserAgentString()); $response = curl_exec($curl); if (!$response) { $err = curl_error($curl); $errNo = curl_errno($curl); throw new Exception('HTTP communication error: ' . $errNo . ', ' . $err); } curl_close($curl); $decoded = json_decode($response, true); if ($jsonErr = $this->isJsonError()) { throw new Exception('JSON Error: ' . $jsonErr); } return $decoded; }