PHP code example of darkfriend / php5-curl
1. Go to this page and download the library: Download darkfriend/php5-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/ */
darkfriend / php5-curl example snippets
$url = 'http://site.ru';
$curl = \darkfriend\helpers\CurlHelper::getInstance();
$response = $curl->request($url);
// $response - array response site.ru
// $curl->lastCode - response http code
// $curl->lastHeaders - response http headers
$url = 'http://site.ru';
$curl = \darkfriend\helpers\CurlHelper::getInstance();
$response = $curl->setHeaders([
'Accept-Language' => 'ru-RU',
'Custom-Head' => 'custom',
])
->request($url);
// $response - array response site.ru
// $curl->lastCode - response http code
// $curl->lastHeaders - response http headers
$url = 'http://site.ru';
$curl = \darkfriend\helpers\CurlHelper::getInstance(false,[
'debug' => true,
'debugFile' => __DIR__.'/logs'
]);
$response = $curl->request($url);
// $response - array response site.ru
// $curl->lastCode - response http code
// $curl->lastHeaders - response http headers
CurlHelper::getInstance($newSession = false, $options = [])->request($url, $data = [], $method = 'post', $requestType = '', $responseType = 'json')