我试图在远程xml文件中发出请求,我收到服务器的回复说:
"Access denied, only compressed data can be send"
所以我尝试在我的请求中使用:
$guzzleClient = new Client();
$feed_response = $guzzleClient->request('GET', $url,[
'headers' => [
'Accept-encoding: gzip'
],
'debug' => true
]);
echo $feed_response->getStatusCode();
但它不起作用,它给了我同样的错误,但如果我使用curl的例子:
curl -sH 'Accept-encoding: gzip' "domain/xmlfile" --compressed
它运作正常,有人能告诉我guzzle选项缺少什么吗?
答案 0 :(得分:0)
解决方案是:
$feed_response = $guzzleClient->request('GET', $url,[
'headers' => ['Accept-Encoding' => 'deflate, gzip'],
// 'debug' => true
]);