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