Office 365 API - 请求返回 HTTP 错误 400
Office 365 API - Request returned HTTP error 400
我正在尝试按照教程从 Office 365 API 中提取邮件和日历事件。我能够提取邮件,但是当我尝试提取日历事件时,我收到错误 400,从一些谷歌搜索中,这显然是我的 headers 之一太长了。我放了一个var_dump(getallheaders());
,可以看到如下:
array (size=10)
'Host' => string 'localhost:9999' (length=14)
'Connection' => string 'keep-alive' (length=10)
'Pragma' => string 'no-cache' (length=8)
'Cache-Control' => string 'no-cache' (length=8)
'Accept' => string 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' (length=74)
'Upgrade-Insecure-Requests' => string '1' (length=1)
'User-Agent' => string 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36' (length=121)
'Accept-Encoding' => string 'gzip, deflate, sdch' (length=19)
'Accept-Language' => string 'en-US,en;q=0.8' (length=14)
'Cookie' => string 'PHPSESSID=286082ac61749c4e351c1218495859bb; SQLiteManager_currentLangue=2' (length=73)
我觉得这一切都很好。我错过了什么?
EDIT - 当我执行 $response = curl_exec($curl);
后跟 var_dump($response);
我得到这个:
string '{"error":{"code":"RequestBroker-ParseUri","message":"The $orderby expression must evaluate to a single value of primitive type."}}' (length=130)
$orderby 表达式的函数是这样的:
public static function getEvents($access_token, $user_email) {
$getEventsParameters = array (
// Only return Subject, Start, and End fields
"$select" => "Subject,Start,End",
// Sort by Start, oldest first
"$orderby" => "Start",
// Return at most 10 results
"$top" => "10"
);
$getEventsUrl = self::$outlookApiUrl."/Me/Events?".http_build_query($getEventsParameters);
return self::makeApiCall($access_token, $user_email, "GET", $getEventsUrl);
}
好的。问题是我们更改了 Start
属性 的类型。它现在是一个复杂的类型。您想要对 Start
属性 的 DateTime
属性 进行排序,因此您想要更改此行:
"$orderby" => "Start",
为此:
"$orderby" => "Start\DateTime",
我以为我们已经更新了教程,但我发现 PHP 没有更新。今天我会努力解决这个问题!
我正在尝试按照教程从 Office 365 API 中提取邮件和日历事件。我能够提取邮件,但是当我尝试提取日历事件时,我收到错误 400,从一些谷歌搜索中,这显然是我的 headers 之一太长了。我放了一个var_dump(getallheaders());
,可以看到如下:
array (size=10)
'Host' => string 'localhost:9999' (length=14)
'Connection' => string 'keep-alive' (length=10)
'Pragma' => string 'no-cache' (length=8)
'Cache-Control' => string 'no-cache' (length=8)
'Accept' => string 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' (length=74)
'Upgrade-Insecure-Requests' => string '1' (length=1)
'User-Agent' => string 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36' (length=121)
'Accept-Encoding' => string 'gzip, deflate, sdch' (length=19)
'Accept-Language' => string 'en-US,en;q=0.8' (length=14)
'Cookie' => string 'PHPSESSID=286082ac61749c4e351c1218495859bb; SQLiteManager_currentLangue=2' (length=73)
我觉得这一切都很好。我错过了什么?
EDIT - 当我执行 $response = curl_exec($curl);
后跟 var_dump($response);
我得到这个:
string '{"error":{"code":"RequestBroker-ParseUri","message":"The $orderby expression must evaluate to a single value of primitive type."}}' (length=130)
$orderby 表达式的函数是这样的:
public static function getEvents($access_token, $user_email) {
$getEventsParameters = array (
// Only return Subject, Start, and End fields
"$select" => "Subject,Start,End",
// Sort by Start, oldest first
"$orderby" => "Start",
// Return at most 10 results
"$top" => "10"
);
$getEventsUrl = self::$outlookApiUrl."/Me/Events?".http_build_query($getEventsParameters);
return self::makeApiCall($access_token, $user_email, "GET", $getEventsUrl);
}
好的。问题是我们更改了 Start
属性 的类型。它现在是一个复杂的类型。您想要对 Start
属性 的 DateTime
属性 进行排序,因此您想要更改此行:
"$orderby" => "Start",
为此:
"$orderby" => "Start\DateTime",
我以为我们已经更新了教程,但我发现 PHP 没有更新。今天我会努力解决这个问题!