PHP code example of vis / curl_client_l5

1. Go to this page and download the library: Download vis/curl_client_l5 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/ */

    

vis / curl_client_l5 example snippets


$curl = New Vis/CurlClient/CurlClient();

//example of all possible methods
$curl->setRequestCredentials($login, $password, $authType) //$authType is optional
     ->setRequestHeader($option, $value) //$option accepts array ["option" => "value", "option1" => "value1"]
     ->setRequestCookie($option, $value) //$option accepts array ["option" => "value", "option1" => "value1"]
     ->setRequestReferrer($referrer)
     ->setRequestUserAgent($agent)
     ->setRequestMethod($method) // 'POST', 'GET', 'PUT', 'PATCH', 'DELETE'
     ->setRequestUrl($url,$urlParams) //$urlParam is optional if you need to add params to query string
     ->setRequestPayload($payload, $encoding) // $encoding is optional. Accepts either 'json' or 'query' and encodes payload to given format, otherwise doesn't encode.
     ->setCurlOpt($option, $value) //if you need to set any other additional curl options

$curl->doCurlRequest() //returns self

$curl->getCurlResponse();  //returns array ['http_code', 'response_header', 'response_body']

$curl->getCurlResponseHttpCode(); //returns http_code
$curl->getCurlResponseHeader(); //returns response_header
$curl->getCurlResponseBody(); //returns response_body

$curl->isSuccessful();

 $curl->doCloseCurl();