PHP code example of andreymukha / simple_curl

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

    

andreymukha / simple_curl example snippets


//Инициализация нового экземпляра класса
$curl = curl::create('http://site.ru/');

//Установка своих параметров, например:
$curl->set(CURLOPT_HEADER, true);

$curl->setHeader(true)
->setReferer('http://site.ru/')
->setFollow(true)
->setUagent('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0')
->setCookie('cookie')
->setDisableSSL()

//Если хотите указать конкретный прокси
->setProxy('192.168.1.1:8080')

//Использует автоматический сервис для выдачи прокси
->setProxy('auto')

//Для POST запросов
->setQuery('POST', $data_array);

//Можно для следующего запроса переключиться на другой тип
->setQuery('GET');

$data = $curl->request('page/1');
 
//Если надо конвертировать данные из одной кодировки в другую
$data = $curl->request('page/1', 'windows-1251', 'utf-8');