mirror of
https://github.com/halaxa/json-machine.git
synced 2025-01-17 13:08:16 +01:00
24 lines
656 B
PHP
24 lines
656 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use JsonMachine\Items;
|
|
use Symfony\Component\HttpClient\HttpClient;
|
|
use Symfony\Contracts\HttpClient\ResponseStreamInterface;
|
|
|
|
require_once __DIR__.'/../../vendor/autoload.php';
|
|
|
|
function httpClientChunks(ResponseStreamInterface $responseStream)
|
|
{
|
|
foreach ($responseStream as $chunk) {
|
|
yield $chunk->getContent();
|
|
}
|
|
}
|
|
|
|
$client = HttpClient::create();
|
|
$response = $client->request('GET', 'https://httpbin.org/anything?key=value');
|
|
$jsonChunks = httpClientChunks($client->stream($response));
|
|
foreach (Items::fromIterable($jsonChunks, ['pointer' => '/args']) as $key => $value) {
|
|
var_dump($key, $value);
|
|
}
|