Guzzle 6异步请求返回传递的参数1必须是类型数组,字符串给定,

时间:2016-09-12 14:39:59

标签: laravel guzzle guzzle6

我正在尝试进行异步POST调用,但guzzle调用会返回以下错误:

Request.php第220行中的

ErrorException: 参数1传递给Symfony \ Component \ HttpFoundation \ Request :: __ construct()必须是类型数组,给定字符串,在第87行的C:\ Program Files ... \ app \ Http \ Controllers \ ConfirmAccountController.php中调用已定义

在ConfirmAccountController中:

$client = new Client(['base_uri' => 'correct_api_address']);

$request = new Request('POST', 'testpromoboiler/updateUser',  [
        'query' => ['token' => $user->sdg_token ,
                    'address' => $user->address ,
                  ]
    ]);

$promise = $client->sendAsync($request)->then(function ($response) {
    echo 'I completed! ' . $response->getBody();
});

$promise->wait();

为什么我收到此错误?

我已经完成了另外两个同步调用,一切顺利。

由于

1 个答案:

答案 0 :(得分:0)

该代码实例化Laravel框架SQL> with tbl(str) as ( select 'Aabjggaklkjha' from dual ) select level as position from tbl where upper(REGEXP_SUBSTR(str, '.', 1, level)) = 'A' connect by level <= length(str); POSITION ---------- 1 2 7 13 SQL> 类。

改为使用guzzles请求方法:

Request