php - 分块调用 Microsoft Graph 日历时出现 504 网关超时
问题描述
当我使用 Postman 时,它可以完美运行。但是,如果我在 PHP 中使用相同的标头,则会出现504 Gateway Time-out
错误。
这就是我调用请求的方式:
$headers = [
'Authorization' => 'Bearer ' . $this->getAccessToken(),
'Cache-Control' => 'private',
'Transfer-Encoding' => 'chunked',
'Content-Type' => 'application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8',
'Content-Encoding' => 'gzip',
'Vary' => 'Accept-Encoding',
'x-ms-ags-diagnostic' => '{"ServerInfo":{"DataCenter":"West Europe","Slice":"SliceC","Ring":"5","ScaleUnit":"003","RoleInstance":"AGSFE_IN_12","ADSiteName":"WEU"}}',
'Preference-Applied' => 'odata.track-changes',
'OData-Version' => '4.0'
];
$request = $this->guzzle->get('v1.0/me/calendarview/delta?startdatetime=2019-12-12T00:00:00Z&enddatetime=2019-12-13T00:00:00Z', ['headers' => $headers]);
print_r($request->getBody());
一旦我更改Transfer-Encoding
为chunked
(就像在 Postman 中一样),我就会收到网关错误。如果我不使用它,我就不会得到日历事件。
解决方案
我认为这与odata.streaming=true;IEEE754Compatible=false;
内容类型标题中的有关。通过此标头,您可以告诉 Microsoft 您希望保持连接打开并接收其他更改。(我什至不知道他们支持。)
根据文档,您不需要发送这些额外的标头。
推荐阅读
- javascript - Array() 构造函数和使用 Array Literal 的不同交互
- php - 选择所有行和软删除的行,而不是在搜索日期之前删除
- android - 如果一个 api 返回 null 值,则调用另一个 api
- jquery - 使用 AJAX 和 Django 进行 GPIO 控制
- sql - PostgreSQL 中按列值的搜索性能
- dart - 从文件路径中打开图像
- python - keras:测试数据能否用于 early_stoppage 和模型检查点
- django - Django Admin Filter List Filter based on User Name for non-admins
- python - Ms Computer Vision API 图像 url 使用 Python 替换为本地 .jpg
- mongodb - MongoDB响应