Eklablog Tous les blogs
Editer l'article Suivre ce blog Administration + Créer mon blog
MENU

Publicité

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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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());
}
$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());
}
 
Publicité
Retour à l'accueil
Partager cet article
Repost0
Pour être informé des derniers articles, inscrivez vous :
Commenter cet article