【发布时间】:2018-07-19 12:05:21
【问题描述】:
我已获得访问令牌,但我很难了解您随后如何发送所需数据的请求。在示例Call Microsoft Graph 中,他们有:
获取 https://graph.microsoft.com/v1.0/me/messages?$select=subject,from,receivedDateTime&$top=25&$orderby=receivedDateTime%20DESC 接受:application/json 授权:Bearer token
但是将 Accept: 和 Authorization: 解析到 Microsoft Graph 的方法是什么?
我已尝试作为 POST,但它显示不记名令牌为空。
$token=$_SESSION['$token'];
$url = 'https://graph.microsoft.com/v1.0/me/calendarview?startdatetime=2018-02-08T18:29:54.171Z&enddatetime=2018-02-15T18:29:54.171Z';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $url,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => array(
Authorization => 'Bearer ' . $token,
Content-Type => 'application/json'
)
)
);
$resp = curl_exec($curl);
curl_close($curl);
【问题讨论】:
-
您看过 MS 的 ADAL 库吗?很多图API调用的例子github.com/AzureAD
-
不是 100% 熟悉 CURL,但“授权”“承载 XxYyZy”应该是一个标题,而不是在发布的字段中。