PHP code example of tommyseus / guzzlehttp-middleware
1. Go to this page and download the library: Download tommyseus/guzzlehttp-middleware 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/ */
tommyseus / guzzlehttp-middleware example snippets
$stack = \GuzzleHttp\HandlerStack::create();
$stack->push(\GuzzleHttp\Middleware::mapResponse(new \Seus\GuzzleHttp\Middleware\Encoding('UTF-8')));
return new \GuzzleHttp\Client([
'handler' => $stack,
]);
/* @var $client \GuzzleHttp\Client */
$promise = $client->requestAsync('GET', '......');
$promise->then(new \Seus\GuzzleHttp\Middleware\Encoding('UTF-8'));
$promise->then(
function (\Psr\Http\Message\ResponseInterface $res) {
echo $res->getStatusCode();
}
);
$promise->wait();