Вопрос

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.

Это было полезно?

Решение 2

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'];
?>

Другие советы

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

Getting the user's name and profile picture using REST

Getting and working with user contact info using REST

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top