Log-in the user with LightOpenID

后端 未结 4 894
悲&欢浪女
悲&欢浪女 2020-12-05 01:25

Hello
I have downloaded LightOpenID (http://gitorious.org/lightopenid) few hours ago but still can\'t figure out how to make it work.
I got this google example saved

4条回答
  •  盖世英雄少女心
    2020-12-05 01:49

    when a user clicked on 'Login with Google' button on 'example-google.php page you will be redirected to google and if user accept the request he will be redirected to your page again and you can get only the Openid of user.

    But if you want to get some other info or change the OpenID provide you can to it on this way:

    mode) {
        if(isset($_GET['oidType'])) {
    $oidType = $_GET['oidType'];
    $openid = new LightOpenID;
        if ($oidType==1)
        {
            $openid->identity = 'https://www.google.com/accounts/o8/id';
        }
        else
        {
            $openid->identity = 'https://me.yahoo.com ';
        }
        $openid->required = array(
          'namePerson',
          'namePerson/first',
          'namePerson/last',
          'contact/email',
        );
        $openid->returnUrl = 'http://www.yourdomain.com/login.php';
        header('Location: ' . $openid->authUrl());
    
        }
    ?>
    Login with Google
    Login with Yahoo
    mode == 'cancel') {
        echo 'User has canceled authentication!';
    } 
    
    } elseif($openid->validate()) {
    $openid_identity = $openid->identity;
        $data = $openid->getAttributes();
        $email = $data['contact/email'];
        $namePerson = $data['namePerson'];
        $first = $data['namePerson/first'];
        $last = $data['namePerson/last'];
    
    echo "Openid:$identitystr 
    "; echo "Email : $email
    "; echo "namePerson : $namePerson
    "; echo "first : $first
    "; echo "last : $last
    "; } else { echo "The user has not logged in"; } } catch(ErrorException $e) { echo $e->getMessage(); }

提交回复
热议问题