Begin by installing this package through Composer. Edit your project's composer.json
file to require cornford/guzzle-cloudflare-middleware
.
"require": {
"cornford/guzzle-cloudflare-middleware": "1.*"
}
Finally, update Composer from the Terminal:
composer update
It's really as simple as using the middleware class with Guzzle:
use GuzzleHttp\Client;
use Cornford\GuzzleCloudflareMiddleware\CloudflareMiddleware;
use GuzzleHttp\Cookie\FileCookieJar;
$client = new Client(['cookies' => new FileCookieJar('cookies.txt')]);
$client->getConfig('handler')->push(CloudflareMiddleware::create());
$res = $client->request('GET', 'http://www.exemple.com/');
echo $res->getBody();
guzzle-cloudflare-middleware is open-sourced software licensed under the MIT license