![](/img/trans.png)
[英]Guzzle 6 Async request return Argument 1 passed must be of the type array, string given,
[英]use Guzzle 6 to request Ruckus public API, but get Argument 3 passed to GuzzleHttp\Client::request() must be of the type array, boolean given
我正在使用Guzzle 6從Ruckus公共API檢索數據,但始終收到以下錯誤
傳遞給GuzzleHttp \\ Client :: request()的參數3必須為數組類型,給定布爾值
我已經用谷歌搜索了類似的問題。 唯一的工作就是圍繞在這第二個答案后是狂飲版降級到5然而,其他隊員做其他功能使用狂飲6,所以降級到5.0版本也可能成為球隊的一個問題。
由於我沒有使用該貼子中的任何軟件包,因此我不認為Guzzle版本可能是這里的罪魁禍首,所以有人可以告訴我我做錯了什么嗎? 謝謝。
順便說一句,我正在使用Laravel命令。 handle函數中的代碼如下:
use Illuminate\Console\Command;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Client;
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$client = new Client();
//to bypass local ssl certificate issuer
$client->setDefaultOption('verify', false);
$res = $client->request(
'POST',
$this->baseUrl . '/v4_0/session',
[
"headers" => [
"Content-Type" => "application/json;charset=UTF-8"
],
"json" => [
"username" => "admin",
"password" => "admin"
]
]
);
$headers = explode(';', $res->getHeader('Set-Cookie'));
return current($headers);
}
Ruckus公共API: http : //docs.ruckuswireless.com/vscg-enterprise/vsz-e-public-api-reference-guide-3-5.html#header-overview 。 我正在使用版本4,但是即使使用版本5,我仍然會遇到相同的錯誤。
最后,我在Guzzle的github帳戶上記錄了一個問題。 原來$client->setDefaultOption('verify', false);
不再是受支持的函數調用。 而是應將其傳遞給如下所示的第三個參數:
$res = $client->request(
'POST',
$this->baseUrl . '/v4_0/session',
[
"verify" => false,
"headers" => [
"Content-Type" => "application/json;charset=UTF-8"
],
"json" => [
"username" => "admin",
"password" => "admin"
]
]
);
感謝您提供建議並嘗試提供幫助的所有人。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.