How to Login with Microsoft Live Account PHP
This post explains you how to implement login Microsoft Live account using PHP.
For login , we need Client Secret Key and Client ID . Click Here To create Microsoft application that will provide client id and password.
Open the above url and fill "app name" and "redirect url" .
Application id is your client ID and application secret is client secret key.
Our api is created successfully.
Now we need to create 2 php pages one for login and second one for receive user data as response from microsoft app.
First create a link on your login page , that will redirect to user on our microsoft login page(mslogin).
<a href="mslogin.php">Login with Microsoft</a>
Then create a page mslogin.php and paste below code
mslogin.php
Now when user click on that link then he will redirect to microsoft login page and after login through microsoft he will redirect to our response url . we already saved redirect url into our app.
Now create response.php
Now run your mslogin.php and try to login with microsoft live ID. oh it works great. :)
This post explains you how to implement login Microsoft Live account using PHP.
For login , we need Client Secret Key and Client ID . Click Here To create Microsoft application that will provide client id and password.
Open the above url and fill "app name" and "redirect url" .
Application id is your client ID and application secret is client secret key.
Our api is created successfully.
Now we need to create 2 php pages one for login and second one for receive user data as response from microsoft app.
First create a link on your login page , that will redirect to user on our microsoft login page(mslogin).
<a href="mslogin.php">Login with Microsoft</a>
Then create a page mslogin.php and paste below code
mslogin.php
<?php $client_id = "YOUR-CLIENT-ID"; $redirect_uri = "https://your-site.com/response.php"; //you can also use localhost url for testing but first add url into microsoft app redirect url then you can use localhost url $urls = 'https://login.live.com/oauth20_authorize.srf?client_id='.$client_id.'&scope=wl.signin%20wl.basic%20wl.emails%20wl.contacts_emails&response_type=code&redirect_uri='.$redirect_uri; header("Location: " .$urls); ?>
Now when user click on that link then he will redirect to microsoft login page and after login through microsoft he will redirect to our response url . we already saved redirect url into our app.
Now create response.php
<?php if(isset($_GET['code']) && $_GET['code']!="") { $auth_code = $_GET["code"]; $client_id = "YOUR-CLIENT-ID"; $client_secret = "Your-API-PASSWORD"; $redirect_uri = "https://your-site.com/response.php"; $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; $get_profile_url='https://apis.live.net/v5.0/me?access_token='.$accesstoken; $xmlprofile_res=curl_file_get_contents($get_profile_url); $profile_res = json_decode($xmlprofile_res, true); if($profile_res) { echo "<pre>"; print_r($profile_res); echo "</pre>"; //this will print output of user info $userid = $profile_res['id']; $login_name = $profile_res['name']; $fname = $profile_res['first_name']; $lname = $profile_res['last_name']; $email = $profile_res['emails']['account']; } } ?>
Now run your mslogin.php and try to login with microsoft live ID. oh it works great. :)
Did you hear there is a 12 word phrase you can communicate to your crush... that will induce deep feelings of love and instinctual attraction to you buried within his chest?
ReplyDeleteThat's because hidden in these 12 words is a "secret signal" that triggers a man's instinct to love, adore and guard you with his entire heart...
12 Words Will Fuel A Man's Desire Instinct
This instinct is so hardwired into a man's mind that it will drive him to try harder than ever before to build your relationship stronger.
Matter-of-fact, fueling this powerful instinct is absolutely binding to having the best possible relationship with your man that the instance you send your man a "Secret Signal"...
...You'll immediately find him expose his mind and soul to you in a way he never expressed before and he'll recognize you as the one and only woman in the galaxy who has ever truly understood him.
Your Affiliate Money Printing Machine is waiting -
ReplyDeleteAnd getting it set up is as simple as 1..2..3!
Here is how it works...
STEP 1. Input into the system which affiliate products you want to promote
STEP 2. Add PUSH BUTTON TRAFFIC (this LITERALLY takes 2 minutes)
STEP 3. Watch the system grow your list and sell your affiliate products all for you!
So, do you want to start making profits???
Check it out here
This is how my friend Wesley Virgin's autobiography begins with this SHOCKING AND CONTROVERSIAL video.
ReplyDeleteWesley was in the army-and soon after leaving-he found hidden, "self mind control" secrets that the CIA and others used to get everything they want.
As it turns out, these are the EXACT same methods many celebrities (notably those who "come out of nowhere") and top business people used to become wealthy and famous.
You probably know how you utilize only 10% of your brain.
That's mostly because the majority of your brain's power is UNCONSCIOUS.
Perhaps this conversation has even taken place INSIDE OF YOUR very own brain... as it did in my good friend Wesley Virgin's brain 7 years back, while driving an unlicensed, beat-up garbage bucket of a vehicle with a suspended license and $3 in his bank account.
"I'm absolutely fed up with living paycheck to paycheck! When will I finally make it?"
You took part in those types of conversations, ain't it so?
Your own success story is going to be written. You just have to take a leap of faith in YOURSELF.
Take Action Now!
function curl_file_get_contents($url) {
ReplyDelete$curl = curl_init();
curl_setopt($curl, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
$data = curl_exec($curl);
curl_close($curl);
return $data;
}