0

我正在使用 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();
}

有人可以帮助我吗?

非常感谢

玩小子

4

0 回答 0