| Issue 19: | Example error | |
| 1 person starred this issue and may be notified of changes. | Back to list |
Hi,
I had difficulties with your example.php, because the openId provider that I was using as test (Hyves.nl) uses POST callbacks rather than GET. So your login example failed because it only looks at $_GET['openid_mode']. I fixed this, and I also merged the Google example into the regular example (might be more convenient for most people). You might not agree with the latter, however here is the code.
Thanks!
Niels
>---
try {
$openid_mode = '';
if (isset($_GET['openid_mode']) ){
$openid_mode=$_GET['openid_mode'];
} else if (isset($_POST['openid_mode'])) {
$openid_mode=$_POST['openid_mode'];
}
if($openid_mode=='' ) {
if (isset($_POST['openid_identifier'])) {
$openid = new LightOpenID;
// Google only provider
if (strpos($_POST['openid_identifier'],'google')!==FALSE ||
strpos($_POST['openid_identifier'],'gmail')!==FALSE) {
$openid->identity = 'https://www.google.com/accounts/o8/id';
} else {
$openid->identity = $_POST['openid_identifier'];
}
header('Location: ' . $openid->authUrl());
}
?>
<form action="" method="post">
OpenID: <input type="text" name="openid_identifier" /> <button>Submit</button>
</form>
<?php
} elseif ($openid_mode == 'cancel' ) {
echo 'User has canceled authentication!';
} else {
$openid = new LightOpenID;
echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.';
}
} catch(ErrorException $e) {
echo $e->getMessage();
}
Nov 22, 2010
Project Member
#1
mewp...@gmail.com
Status:
Started
Nov 22, 2010
I have added $openid->mode that returns openid.mode either from $_GET or $_POST, depending on where it's avaiable.
Status:
Fixed
Nov 24, 2010
That's cool, thanx! |