虽然URL显示两者,但LightOpenID不返回标识或电子邮件

时间:2011-07-19 15:24:13

标签: php model-view-controller localhost lightopenid

我使用MVC模式和LightOpenID来获取登录详细信息,但$openid->mode$openid->validate()在行header('Location: ' . $openid->authUrl());之后变为空

以下是代码:

<?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 ';
                    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();
}

有人可以帮我吗?

非常感谢

PlayKid

0 个答案:

没有答案