Skip to content

Instantly share code, notes, and snippets.

@sasezaki
Created July 15, 2014 14:51
Show Gist options
  • Save sasezaki/415e758629a15b7e7994 to your computer and use it in GitHub Desktop.
Save sasezaki/415e758629a15b7e7994 to your computer and use it in GitHub Desktop.
{
"require": {
"guzzlehttp/guzzle": "4.1.*@dev",
"guzzlehttp/streams": "dev-master"
}
}
<?php
use GuzzleHttp\Adapter\StreamAdapter;
use GuzzleHttp\Message\MessageFactory;
require_once __DIR__.'/vendor/autoload.php';
$config = [
'adapter' => new StreamAdapter(new MessageFactory)
];
$client = new GuzzleHttp\Client();
$r = $client->get('http://example.com');
$stream = $r->getBody()->detach();
fseek($stream, 0, SEEK_SET);
stream_copy_to_stream($stream, STDOUT);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment