LightOpenID not returning the Identity or E-mail although the URL displays the both
I am using a MVC pattern and LightOpenID to get a login details, but $openid->mode
and $openid->validate()
became null after the line header('Location: ' . $openid->authUrl());
Here is the code:
<?php
session_start();
try {
# Change 'localhost' to your domain name.
$openid = new LightOpenID('localhost:81');
if(!$openid->mode) {
if(isset($provider)) {
switch ($provider) {
case 'google':
$openid->identity = 'https://www.google.com/accounts/o8/id';
break;
case 'yahoo':
$openid->identity = 'https://me.yahoo.com开发者_如何学Go ';
break;
}
$openid->required = array('namePerson/friendly', 'contact/email');
$openid->returnUrl = 'http://localhost:81/test/';
header('Location: ' . $openid->authUrl());
//All return variables became NULL here.
}
} elseif($openid->mode == 'cancel') {
echo 'User has canceled authentication!';
} else {
if ($openid->validate()) {
$returnVariable = $openid->getAttributes();
//echo $returnVariable['contact/email'];
$_SESSION['email'] = $returnVariable['contact/email'];
}
}
} catch(ErrorException $e) {
echo $e->getMessage();
}
Can someone asssit me?
Many Thanks
PlayKid
精彩评论