微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php-如何使用guzzleHttp创建请求?

我使用了GuzzleHttp,创建了以下命令请求:

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

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

但是错误

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

我为什么想念?我认为参数是正确的!

解决方法:

这样做的原因是针对Guzzle 5.x,但是,该消息很可能来自于6.x版本.我会发布指向文档6.x版本的链接,但我只能找到http://guzzle.readthedocs.org/en/latest/quickstart.html
并且没有语义版本.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐