简体   繁体   English

Laravel:GuzzleHttp客户端

[英]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.

相关问题 Laravel:找不到类“GuzzleHttp\Client” - Laravel: Class 'GuzzleHttp\Client' not found Laravel 5.5上的GuzzleHttp \\ Client 400错误请求 - GuzzleHttp\Client 400 bad request on Laravel 5.5 Laravel,Mailgun'Class GuzzleHttp \找不到客户名称' - Laravel, Mailgun 'Class GuzzleHttp\Client name not found' Laravel GuzzleHttp-两个laravel应用程序-客户端检查模型 - Laravel guzzleHttp - two laravel application - checking model in client side 尝试使用laflavel中的guzzlehttp客户端上传多个图像 - Trying to upload multiple images using guzzlehttp client in laravel 未找到Laravel Class'App \\ Http \\ Controllers \\ GuzzleHttp \\ Client' - Laravel Class 'App\Http\Controllers\GuzzleHttp\Client' not found 为什么即使在 Laravel 中安装了“找不到类‘GuzzleHttp\\Client’”? - Why "Class 'GuzzleHttp\Client' not found" even after Installing it in Laravel? Laravel 5.1 GuzzleHttp Client错误:使用Mailgun时出现404 - Laravel 5.1 GuzzleHttp Client error: 404 when using mailgun Laravel 6:FatalThrowableError:在 TransportManager.php 中找不到类“GuzzleHttp\\Client” - Laravel 6: FatalThrowableError: Class 'GuzzleHttp\Client' not found in TransportManager.php 找不到Laravel 5.3提供程序类'GuzzleHttp \\ Guzzle \\ Client' - Laravel 5.3 Providers Class 'GuzzleHttp\Guzzle\Client' not found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM