Example #1
0
 /**
  * @param $path
  * @param array $params
  * @return array|object
  * @throws \Exception
  */
 public function get($path, array $params = [])
 {
     $this->curl->getUri()->setPath($path);
     try {
         $response = $this->curl->get($params)->getJsonBody();
         if ($response->status === 'error') {
             throw new \Exception($response->response->message);
         }
     } catch (\Exception $exception) {
         throw $exception;
     }
     return $response;
 }
Example #2
0
<?php

namespace HttpClientTest;

use Dez\Http\Client\Provider\Curl;
error_reporting(1);
ini_set('display_errors', 1);
include_once '../vendor/autoload.php';
$curl = new Curl();
$curl->uri('http://my.local/test-curl-redirect.php?go');
$curl->setTimeout(3);
$response = $curl->get();
if ($response->isRedirect()) {
    var_dump($curl->getRedirectURL());
}
die(var_dump($response));