使用Microsoft Graph。当用户登录时,我可以通过以下代码读取所有用户数据:
<?php
session_start();
echo $acc= $_SESSION['access_token'];
echo '<br>display<br>';
echo $_SESSION['preferred_username'];
echo $_SESSION['given_name'];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://graph.microsoft.com/v1.0/me",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
//CURLOPT_CUSTOMREQUEST => "GET",
//CURLOPT_POSTFIELDS => "$data",
CURLOPT_HTTPHEADER => array(
"authorization: Bearer $acc"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
print_r($response);
$json = json_decode($response);
if ($err) {
echo "cURL Error #:" . $err;
} else {
//echo $response;
}
?>
现在,我想通过分别更改https://graph.microsoft.com/v1.0/me/photo/
和https://graph.microsoft.com/v1.0/me/messages
的API连接链接来访问登录用户个人资料照片和电子邮件。
要检索已登录的用户个人资料照片,我收到此错误:
{
"error": {
"code": "GetUserPhoto",
"message": "The operation is not supported.",
"innerError": {
"request-id": "78f2f57f-e256-459e-b515-1adb17cf3b2d",
"date": "2017-11-27T03:22:09"
}
}
}
检索用户的邮件时,我收到此错误:
{
"error": {
"code": "ErrorAccessDenied",
"message": "Access is denied. Check credentials and try again.",
"innerError": {
"request-id": "d5baf587-d08f-47c2-8c2d-160536d36eb6",
"date": "2017-11-27T04:16:15"
}
}
}
请问可能是什么问题。感谢
答案 0 :(得分:0)
您无法使用当前版本的Microsoft Graph从个人帐户中检索个人资料照片。根据{{3}}:
注意 1.0版中的此操作仅支持用户的工作或学校邮箱,而不支持个人邮箱。