Muh*_*qar 5 curl gzip laravel guzzle octobercms
API网址是=,我正在尝试实施:https: //docs.ingresso.co.uk/#basic-booking-flow
我的代码在OctoberCMS中使用GuzzleHttp\Client对象.
$credentials = base64_encode('demo:demopass');
$client = new Client();
$request_url = 'https://demo.ticketswitch.com/f13/events.v1/';
$response = $client->request('GET', $request_url, [
'headers' => ['Accept' => 'application/json','Authorization' => 'Basic ' . $credentials,],
'auth' => ['demo', 'demopass'],
'timeout' => 120
])->getBody()->getContents();
echo "<pre>";
print_r($response);
die();
Run Code Online (Sandbox Code Playgroud)
我正在阅读所有建议的问题,而我正在添加我的问题标题,并且没有关于问题的线索或帮助...帮助.....
注意:任何用户或开发人员都可以使用Api凭据,
该错误表明请求必须gzip:“您必须支持 gzip [才能使用此 API]”。
这是通过发送到服务器的Accept-Encoding标头进行控制的:
Accept-Encoding 请求 HTTP 标头通告客户端能够理解的内容编码(通常是压缩算法)。
服务器强制执行此操作是为了确保客户端在使用 API 时通过使用压缩来节省带宽。这可以降低托管成本和/或提高请求性能。F13 文档仅指出“所有请求都必须使用gzip ”。
Guzzle 请求选项文档中介绍了启用 gzip 传输压缩的使用方法:
// Request gzipped data and automatically decode/decompress it
$client->request('GET', '/foo.js', [
'headers' => ['Accept-Encoding' => 'gzip'],
'decode_content' => true // default is true, added to be explicit
]);
Run Code Online (Sandbox Code Playgroud)
或者,更简单地说
// Pass "gzip" as the Accept-Encoding header and automatically decode/decompress
$client->request('GET', '/foo.js', ['decode_content' => 'gzip']);
Run Code Online (Sandbox Code Playgroud)
当 [decode_content 设置] 为字符串时,响应的字节将被解码,并且提供给decode_content 选项的字符串值将作为请求的 Accept-Encoding 标头传递。
| 归档时间: |
|
| 查看次数: |
64 次 |
| 最近记录: |