通过PHP中的Microsoft Graph 365 API从Microsoft Outlook帐户检索用户个人资料图片时遇到问题 [英] issues Retrieving users profile picture from microsoft outlook account via Microsoft Graph 365 API in PHP

查看:75
本文介绍了通过PHP中的Microsoft Graph 365 API从Microsoft Outlook帐户检索用户个人资料图片时遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正在尝试使用Microsoft 365图形API获取Microsoft Outlook邮件用户的个人资料照片.

Am trying to get microsoft outlook mail users profile photos using microsoft 365 graph API.

我已在应用程序上设置了以下权限User.Read, User.ReadWrite,User.ReadBasic.All,User.Read.All,User.ReadWrite.All ,但未显示任何权限个人资料照片,而用户已在其Outlook邮件帐户中上传了个人资料照片....

I have set the following permissions User.Read, User.ReadWrite, User.ReadBasic.All, User.Read.All, User.ReadWrite.All on the apps ends but its not displaying any profile photos whereas the user has Profile Photos already uploaded on her outlook mail account....

下面是代码

<?php 
session_start();

echo $acc= $_SESSION['access_token'];





$curl = curl_init();

curl_setopt_array($curl, array( 


CURLOPT_URL => "https://graph.microsoft.com/v1.0/me/photo", 
//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);

$res = $json->{'items'};




if ($err) { 
echo "cURL Error #:" . $err; 
} else { 
//echo $response; 
}

?>

推荐答案

您快到了.您要使用的是

You're almost there. What you want to use is

https://graph.microsoft.com/v1.0/me/photo/$value

这篇关于通过PHP中的Microsoft Graph 365 API从Microsoft Outlook帐户检索用户个人资料图片时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆