1
I need to send data by get and pick up what to return to know if it worked or not, however, with Curl and file_get_contents not giving (seems to be the server that receives the request), so I’m trying to use Guzzle, I made a test here and seems to have given no problems, however, I don’t quite know how to see the return of the request, I’m doing so:
require_once 'vendor/autoload.php';
use GuzzleHttp\Client;
use GuzzleHttp\Message\Request;
use GuzzleHttp\Message\Response;
$client = new Client();
$response = $client->get('http://www.endereco.com.br?dados');
var_dump($response->getBody());
He prints this on my screen:
Object(Guzzlehttp Psr7 Stream)#24 (7) { ["stream":"Guzzlehttp Psr7 Stream":private]=> Resource(5) of type (stream) ["size":"Guzzlehttp Psr7 Stream":private]=> NULL ["seekable":"Guzzlehttp Psr7 Stream":private]=> bool(true) ["readable":"Guzzlehttp Psr7 Stream":private]=> bool(true) ["writable":"Guzzlehttp Psr7 Stream":private]=> bool(true) ["Uri":"Guzzlehttp Psr7 Stream":private]=> string(10) "php://temp" ["customMetadata":"Guzzlehttp Psr7 Stream":private]=> array(0) { } }
You can get HTML or json with the server response ?!
Vlw.