我正在尝试按照教程从Office 365 API中提取邮件和日历事件。我能够拉邮件,但是当我尝试拉日历事件时,我得到了错误400,从谷歌搜索中,显然我的一个标题太长了。我放了一个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)
这一切对我来说都很好。我错过了什么?
编辑 - 当我$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);
}
答案 0 :(得分:1)
确定。问题是我们更改了Start
属性的类型。它现在是一个复杂的类型。您想要对DateTime
属性的Start
属性进行排序,因此您需要更改此行:
"\$orderby" => "Start",
对此:
"\$orderby" => "Start\DateTime",
我认为我们已经更新了教程,但我发现PHP版本没有更新。我今天会努力解决这个问题!