1. Go to this page and download the library: Download nicolus/curl 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/ */
nicolus / curl example snippets
use Curl\Curl;
try {
$url = "http://www.google.com";
//A simple GET request (with followlocation and no timeout by default)
echo Curl::get($url);
//A simple POST request (multipart) :
echo Curl::post($url, ["param1" => "value1" ]);
//A simple POST request (x-www-urlencoded) :
echo Curl::post($url, "param1=value1¶m2=value2");
//Using a proxy :
echo (new Curl)
->setUrl($url)
->setProxy("myproxy.com:31280", "username", "password")
->request();
//A more complex request
$curl = new Curl;
echo $curl
->setUrl($url)
->addHeaders(['X-CUSTOMHEADER: aaa', 'pipoheader: bbb'])
->addHeaders('trololo: ccc')
->setAuth("Username", "Password")
->setTimeout(30)
->setUserAgent(Curl::UA_FIREFOX)
->request();
//Get info for the last request :
print_r($curl->getInfo());
} catch (Exception $e) {
echo "erreur avec une requête curl : " . $e->getMessage() ."<br>\n";
echo "code : " . $e->getCode() ."<br>\n";
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.