How to login with hotmail on website? Reviewed by Momizat on . First creat a Application on Hotmail go to:- https://account.live.com/developers/applications Click on the Create Applicatin then open form and fill all details First creat a Application on Hotmail go to:- https://account.live.com/developers/applications Click on the Create Applicatin then open form and fill all details Rating: 0

How to login with hotmail on website?

First creat a Application on Hotmail go to:-

https://account.live.com/developers/applications

My application
Click on the Create Applicatin then open form and fill all details.
Create Application form

Get Client Id and Client Secret For API

API

PHP code hotmail-login.php on website

include_once("hotmail/live_connect.inc.php");
$cnt_live = new MocrosoftLiveCnt(array(
	'client_id' 	=> 'xxxxxxxxxxxxx',
	'client_secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
	'client_scope' 	=> 'wl.basic wl.emails',
	'redirect_url' 	=> 'http://www.site.com/hotmail-login.php'
));
if(!isset($_GET["code"])){
	//$loginUrl = $cnt_live->GetLoginUrl();
	header('Location: '.$cnt_live->GetLoginUrl());
}
//https://login.live.com/oauth20_authorize.srf?client_id=xxxxxxxxxxxxxxxx&scope=wl.basic wl.emails wl.birthday&response_type=code&redirect_uri=http://www.site.com/hotmail-login.php;
$user_info = $cnt_live->getUser();
if(!$user_info && isset($_GET["code"])){
	$access_token="";
	$access_token 	= $cnt_live->getAccessToken($_GET["code"]);

	$cnt_live->setAccessToken($access_token);
	header('Location: '.$cnt_live->GetRedirectUrl());

}
if(isset($_GET["logout"])){
	$cnt_live->distroySession();
	header('Location: '.$cnt_live->GetRedirectUrl());
}
if($user_info){

	 $res=array();
	 if(isset($user_info->emails->account)) $res['email'] = $user_info->emails->account;
	if(isset($user_info->first_name)) $res['users_fname']=$user_info->first_name;
	if(isset($user_info->last_name)) $res['users_lname']=$user_info->last_name;
	$res['id']=$user_info->id;
	print_r($res);

}else{
	//show login button
	header('Location: '.$cnt_live->GetRedirectUrl());
}

Comments (3)

Leave a Comment

© 2014 Powered By