openid验证返回false

时间:2012-04-25 15:52:39

标签: php openid lightopenid

我已经下载了LightOpenID(http://gitorious.org/lightopenid)并且它工作但几天前停止了。我的代码:

<?php
require 'openid.php';
try {
if(!isset($_GET['openid_mode'])) {
    if(isset($_GET['login'])) {
        $openid = new LightOpenID('my-domain.com');
        $openid->identity = 'https://www.google.com/accounts/o8/id';
            $openid->required = array('namePerson/friendly', 'contact/email');
        header('Location: ' . $openid->authUrl());
    }
?>
<form action="?login" method="post">
<button>Login with Google</button>
</form>
<?php
} elseif($_GET['openid_mode'] == 'cancel') {
    echo 'User has canceled authentication!';
} else {
    $openid = new LightOpenID('my-domain.com');
    echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.';
}
} catch(ErrorException $e) {
echo $e->getMessage();
}
echo '<pre>'.print_r($openid,true).'</pre>';
?>

在localhost上它可以工作,但不在Web服务器上。

编辑:我找到了LightOpenID的旧版本,但它确实有效。

1 个答案:

答案 0 :(得分:0)

request_streams()方法存在问题,我通过注释第352行并将其替换为return $ data来解决它;

//return file_get_contents($url, false, $context);
return $data;