PHP code example of otifsolutions / curl-handler

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

    

otifsolutions / curl-handler example snippets

 
use OTIFSolutions\CurlHandler\Curl

getCurlErrors();    // used to display errors if any


use OTIFSolutions\CurlHandler\Curl;
use OTIFSolutions\CurlHandler\Exceptions\CurlException;

try{

    Curl::Make()
        ->GET // this could be, get, post, put, delete
        ->url('REQUEST_URL_GOES_HERE')
        ->header(['AUTHENTICATION_ARRAY_GOES_HERE'])
        ->body(['BODY_ARRAY_GOES_HERE'])
        ->referer('https://www.google.com')
        ->agent('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.12011-10-16 20:23:00')
        ->params(['PARAMETERS_ARRAY_GOES_HERE'])
        ->execute();
}

catch(CurlException $ce){
    return ($ce->getCurlErrors());
}


use OTIFSolutions\CurlHandler\Curl;

Curl::Make()
    ->GET
    ->url('URL_GOES_HERE')
    ->header(['AUTHENTICATION_ARRAY_GOES_HERE'])
    ->params(['PARAMS_ARRAY_GOES_HERE'])
    ->execute();

use OTIFSolutions\CurlHandler\Curl;

Curl::Make()
    ->POST
    ->url('URL_GOES_HERE')
    ->header(['AUTHENTICATION_ARRAY_GOES_HERE'])
    ->body(['BODY_ARRAY_GOES_HERE'])
    ->params(['PARAMS_ARRAY_GOES_HERE'])
    ->execute();

use OTIFSolutions\CurlHandler\Curl;

Curl::Make()
    ->PUT
    ->url('URL_GOES_HERE')
    ->header(['AUTHENTICATION_ARRAY_GOES_HERE'])
    ->body(['BODY_ARRAY_GOES_HERE'])
    ->params(['PARAMS_ARRAY_GOES_HERE'])
    ->execute();

use OTIFSolutions\CurlHandler\Curl;

Curl::Make()
    ->DELETE
    ->url('URL_GOES_HERE')
    ->header(['AUTHENTICATION_ARRAY_GOES_HERE'])
    ->params(['PARAMS_ARRAY_GOES_HERE'])
    ->execute();