Im new to open id, but still i have tried to integrate the open id in my website. Im using yahoo provider to login in to my website. Could any help me in getting the user information like yahoo mail id , first name , last name.
I have take the below code from a website which is provided for google, i have changed the provider to yahoo
Code which i have tried:
<?php
# Logging in with Google accounts requires setting special identity, so this example shows how to do it.
require 'openid.php';
try {
# Change 'localhost' to your domain name.
$openid = new LightOpenID('localhost');
if(!$openid->mode) {
if(isset($_GET['login'])) {
$openid->identity = 'https://me.yahoo.com';
header('Location: ' . $openid->authUrl());
}
?>
<form action="?login" method="post">
<button>Login with Yahoo</button>
</form>
<?php
} elseif($openid->mode == 'cancel') {
echo 'User has canceled authentication!';
} else {
echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.';
print_r($openid->ax_to_sreg);
}
} catch(ErrorException $e) {
echo $e->getMessage();
}
After loggin im getting out put like this :
User https://open.login.yahooapis.com/openidx20/user_profile/XXXX has logged in.
what is the use of above url? How can i fetch the user information?
After googling a lot find my solution. Now im able to fetch the email of logged in user
Here is the modified code :