向 api.ai 发出 guzzle GET 请求时所需的“lang”参数为空

Required ‘lang’ parameter is empty when making guzzle GET request to api.ai

我正在通过 guzzle 向 api.ai 发送 GET 请求,但得到的响应是:

     { "id": "83a493c7-386f-4e0a-93f8-6e3647f0f1be", "timestamp": "2017-07-29T19:40:22.172Z", "lang": "en", "status": { "code": 400, "errorType": "bad_request", "errorDetails": "Required 'lang' parameter is empty." } }

下面是我的代码:

try {  
 $res = $client->request('GET', 'https://api.api.ai/v1/query?
query=weather&lang=\"en\"');        
}
catch (\GuzzleHttp\Exception\ClientException $e) {
$response = $e->getResponse();
$responseBodyAsString = $response->getBody()->getContents();
echo $responseBodyAsString;
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
fwrite($myfile,  \GuzzleHttp\json_encode($e->getResponse('Status'),true));
fclose($myfile); die();

}

这是 url 编码错误。我通过从 url.

中删除 "amp;" 来解决它