1
votes

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

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....

Below is the code

<?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; 
}

?>
1
Welcome to Stack Overflow! Since you are new user, I recommend you read "How to Ask a Good Question". It isn't clear why type of account this is (personal vs work/school) or what error(s) you're getting. - Marc LaFleur

1 Answers

2
votes

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

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