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

后端 未结 7 2889
臣服心动
臣服心动 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:51

    Uservoice users RPX http://rpxnow.com . You can easily use it with PHP, just https and parse the json or xml repsonse. You don't even need to change your database schema or store anything locally.

    0 讨论(0)
  • 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 ) :

    <?php
    require_once 'openid.php';
    $myopenid = new LightOpenID("your-domain.com");//no problem even if u can write http://localhost
    
    if ($myopenid->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 <br>";
            echo "Email : $email <br>";
            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:

    <?php
    require_once 'openid.php';
    $openid = new LightOpenID("your-domain.com");//no problem even if u can write http://localhost
    
    $openid->identity = 'https://www.google.com/accounts/o8/id';
    $openid->required = array(
      'namePerson/first',
      'namePerson/last',
      'contact/email',
    );
    $openid->returnUrl = 'your-domain.com/login.php'
    ?>
    
    
    
    <a href="<?php echo $openid->authUrl() ?>">Login with Google</a>
    

    i almost forgot for log out u can kill session;

    0 讨论(0)
  • 2020-12-25 14:03

    You should look at the OpenID Enablded PHP library (http://www.openidenabled.com/php-openid/).

    This should play pretty nicely with any LAMP installation without needing to use Zend.

    0 讨论(0)
  • Zend_OpenId from Zend Framework

    Zend_OpenId is a Zend Framework component that provides a simple API for building OpenID-enabled sites and identity providers.

    0 讨论(0)
  • 2020-12-25 14:08

    See here: Google Login PHP Class.

    Also be sure to refer to the Google Federated Login site for more info.

    0 讨论(0)
  • 2020-12-25 14:09

    You may want to look at this too: https://rpxnow.com/ - it will only need integrating at the HTML/javascript level.

    It's what http://uservoice.com/login appears to use.

    0 讨论(0)
提交回复
热议问题