How do you enable customers to log in to your site using their Google account?

后端 未结 7 2711
臣服心动
臣服心动 2020-12-25 13:34

I just saw http://uservoice.com/login. It uses Google accounts, Myspace, Yahoo, OpenID and all to sign in customers into its site? Can I do that?

I mean, customers n

7条回答
  •  孤城傲影
    2020-12-25 13:52

    i think is good solution for you step by step

    1-download openid

    2-create file called login.php like this (in same directory or change require_one to your own ) :

    mode) {
        if ($myopenid->mode == 'cancel') {
            echo "User has canceled authentication !";
        } elseif($myopenid->validate()) {
            $data = $myopenid->getAttributes();
            $email = $data['contact/email'];
            $first = $data['namePerson/first'];
            echo "Identity : $openid->identity 
    "; echo "Email : $email
    "; echo "First name : $first"; } else { echo "The user has not logged in"; } } else { echo "Go to index page to log in."; } ?>

    3-next is about creating file called index.php:

    identity = 'https://www.google.com/accounts/o8/id';
    $openid->required = array(
      'namePerson/first',
      'namePerson/last',
      'contact/email',
    );
    $openid->returnUrl = 'your-domain.com/login.php'
    ?>
    
    
    
    Login with Google
    

    i almost forgot for log out u can kill session;

提交回复
热议问题