[英]Laravel : GuzzleHttp Client
I am using "guzzlehttp/guzzle": "~6.0"
and trying to github users using below code . 我正在使用
"guzzlehttp/guzzle": "~6.0"
并尝试使用以下代码github用户。
$client = new \GuzzleHttp\Client();
$request = $client->createRequest('GET', 'https://api.github.com/users');
$query = $request->getQuery();
$query->set('since',135);
$response = $request->send();
$oResponse = json_decode($response->getBody(true));
But I am getting error Argument 3 passed to GuzzleHttp\\Client::request() must be of the type array, string given
But this method works on "guzzle/guzzle": "^3.9",
I don't know where I am missing something. 但是我收到
Argument 3 passed to GuzzleHttp\\Client::request() must be of the type array, string given
错误Argument 3 passed to GuzzleHttp\\Client::request() must be of the type array, string given
但是此方法适用于"guzzle/guzzle": "^3.9",
我不知道我在哪里遗漏了什么。
"guzzlehttp/guzzle": "~6.0"
will get you Guzzle v6.1.1. "guzzlehttp/guzzle": "~6.0"
〜6.0 "guzzlehttp/guzzle": "~6.0"
将为您提供Guzzle v6.1.1。 Methods and method signatures are not the same between v3.9 and v6.1. v3.9和v6.1之间的方法和方法签名不同。 So much so that
Client::createRequest()
does not exist within v6.1 and infact is caught by Client::__call()
and then passed to Client::request()
where you are obtaining your error because provided arguments to not match the signature for Client::request()
. 如此之多,以至于
Client::createRequest()
在v6.1中不存在,并且事实上被Client::__call()
捕获,然后传递给Client::request()
,您在此处获取错误,因为提供的参数不匹配Client::request()
的签名。
More information on Guzzle 6 can be obtained from Guzzle docs . 可以从Guzzle docs获取有关Guzzle 6的更多信息。
You will also find that your $request->send()
will throw an error. 您还会发现
$request->send()
会引发错误。 Guzzle 6 took Psr7 to heart and as such the Request / Response objects implement the Psr7 specification. 食尸鬼6牢记Psr7,因此Request / Response对象实现了Psr7规范。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.