Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to createRequest by using guzzleHttp?

I used GuzzleHttp, I have created request following commands:

use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;

$url = 'http://localhost/api/get_data?token=123456';
$client = new Client();
$request = $client->createRequest('GET', $url, []);

But error:

Argument 3 passed to GuzzleHttp\Client::request() must be of the type array, string given, called in /home/datnq/www/slim/vendor/guzzlehttp/guzzle/src/Client.php on line 88 and defined

Why did I miss ? I think parameters are right!

like image 295
datnq Avatar asked May 31 '26 01:05

datnq


1 Answers

The reason why is that usage is for Guzzle 5.x, however, that message is most likely from using 6.x versions. I'd post a link to the 6.x version of the docs, but all I can find is http://guzzle.readthedocs.org/en/latest/quickstart.html and it isn't semantically versioned.

like image 139
Eric Cope Avatar answered Jun 01 '26 17:06

Eric Cope