PHP code example of faso-dev / simple-curl-client

1. Go to this page and download the library: Download faso-dev/simple-curl-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

faso-dev / simple-curl-client example snippets




use FasoDev\SimpleCurlClient\CurlClient;
use FasoDev\SimpleCurlClient\CurlClientBuilder;

$client = CurlClientBuilder::create()
	->defineProxySslVerifyPeer(false)
	->defineTimeOut(30)
	->defineConnectTimeOut(30)
	->defineUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36')
	->build()
;

$client->get('https://httpbin.org/get');
$client->get('https://httpbin.org/get', ['foo' => 'bar']);
$client->post('https://httpbin.org/post', ['foo' => 'bar']);
$client->post('https://httpbin.org/post', ['foo' => 'bar'], [
    'headers' => [
        'Content-Type' => 'application/json',
        'Accept' => 'application/json',
    ],
    CURLOPT_SSL_VERIFYPEER => true,
]);