PHP code example of s25 / http-client
1. Go to this page and download the library: Download s25/http-client 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/ */
s25 / http-client example snippets
25\HTTPClient\Client;
use S25\HTTPClient\UserAgent;
$client = new Client();
$result = $client->get('http://httpbin.org/headers');
echo $result.PHP_EOL;
// To set random User Agent
$client->setUserAgent(UserAgent::getRandom());
$result = $client->get('http://httpbin.org/headers');
echo $result.PHP_EOL;
// To set alternative header and referer
$client->setHeaders(['Accept-Language' => 'ru,en-US;q=0.9,en;q=0.8,ja;q=0.7,fr;q=0.6,es;q=0.5,de;q=0.4']);
$client->setReferer('https://yandex.ru');
$result = $client->get('http://httpbin.org/headers');
echo $result.PHP_EOL;
// To be continued