Framework\Curl

Curl class helps your application to make curl request. Default CURL options are available in the methods. These will make it simpler to make curl requests for GET, POST, PUT and DELETE. You can also define custom options.

Methods

  • get(string $url, array $params = [], array $options = [])
  • post(string $url, array $fields = [], array $options = [])
  • put(string $url, array $fields = [], array $options = [])
  • delete(string $url, array $fields = [], array $options = [])

Examples

You can make the curl request in this way.

// GET
$curlResponse = 
    \Framework\Curl::get('https://example.com', ['id' => 22]);

// POST
$postParams = Request::post(['user_id']);
$curlResponse = 
    \Framework\Curl::post('https://example.com', $postParams);

You can also set custom options before making the request.

$params = ['id' => 22];
$options[CURLOPT_PORT] = 3899;
$curlResponse = 
    \Framework\Curl::get('https://example.com', $params, $options);