PHP code example of sa / guzzlehttp-cloudflare
1. Go to this page and download the library: Download sa/guzzlehttp-cloudflare 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/ */
sa / guzzlehttp-cloudflare example snippets
$sUrl = 'https://thebot.net/';
$oClient = new \GuzzleHttp\Client([
'cookies' => new \GuzzleHttp\Cookie\FileCookieJar(tempnam('/tmp', __CLASS__)),
'headers' => ['Referer' => $sUrl],
]); // 1. Create Guzzle instance
/** @var \GuzzleHttp\HandlerStack $oHandler */
$oHandler = $oClient->getConfig('handler');
$oHandler->push(\GuzzleCloudflare\Middleware::create()); //2. ???
echo (string)$oClient->request('GET', $sUrl)->getBody(); //3. Profit!!