How to get Hotmail user profile data and email ID from PHP?
Is there any API available for the same?
Any help will be appreciable.
There no such official API for hotmail/outlook/live services from microsoft.
However you can use RESTful calls using Identity API to get user details.
This might help
here is the code for get hotmail user profile detail
<?php
$client_id = 'Your client id';
$client_secret = 'client secret key';
$redirect_uri = 'redirect url';
$auth_code = $_GET["code"];
// get contacts
$fields=array(
'code'=> urlencode($auth_code),
'client_id'=> urlencode($client_id),
'client_secret'=> urlencode($client_secret),
'redirect_uri'=> urlencode($redirect_uri),
'grant_type'=> urlencode('authorization_code')
);
$post = '';
foreach($fields as $key=>$value) { $post .= $key.'='.$value.'&'; }
$post = rtrim($post,'&');
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,'https://login.live.com/oauth20_token.srf');
curl_setopt($curl,CURLOPT_POST,5);
curl_setopt($curl,CURLOPT_POSTFIELDS,$post);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,TRUE);
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,0);
$result = curl_exec($curl);
curl_close($curl);
$response = json_decode($result);
$accesstoken = $response->access_token;
$my_url = "https://apis.live.net/v5.0/me?access_token=".$accesstoken;
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,$my_url);
$myres=curl_exec($ch);
curl_close($ch);
$myxml = json_decode($myres, true);
$myemailid = $myxml['emails']['account'];
$username = $myxml['name'];
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.