1
0
mirror of https://github.com/halaxa/json-machine.git synced 2025-07-15 11:36:21 +02:00
Files
json-machine/examples/guzzleHttp.php
2022-02-03 21:56:47 +01:00

14 lines
432 B
PHP

<?php
declare(strict_types=1);
require_once __DIR__.'/../../vendor/autoload.php';
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://httpbin.org/anything?key=value');
// Gets PHP stream resource from Guzzle stream
$phpStream = \GuzzleHttp\Psr7\StreamWrapper::getResource($response->getBody());
foreach (\JsonMachine\Items::fromStream($phpStream) as $key => $value) {
var_dump([$key, $value]);
}