PHP code example of phpcurl / curlwrapper

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

    

phpcurl / curlwrapper example snippets


class MyApiClient {
    ...
    function call($url)
    {
        $ch = curl_init($url);
        curl_set_opt($ch, /*...*/)
        return curl_exec($ch);
    }
}

class MyApiClient {
    private $curl;
    function __construct(\PHPCurl\CurlWrapper\CurlInterface $curl)
    {
        $this->curl = $curl;
    }
    //...
    function call($url)
    {
        $this->curl->init($url);
        $this->curl->setOpt(/*...*/)
        return $this->curl->exec();
    }
}