How do you enable customers to log in to your site

2019-02-01 08:26发布

问题:

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 need not register to my site. They can just sign in with their accounts on the above sites.

If you've a solution, I'd prefer a PHP and MySQL based one.

回答1:

See here: Google Login PHP Class.

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



回答2:

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.



回答3:

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.



回答4:

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.



回答5:

http://openidenabled.com/php-openid/



回答6:

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.



回答7:

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;