我想使用OpenID实现使用Google帐户的登录,但我不知道如何启动此过程,因为我不知道如何执行此操作.那么有一个一步一步的指南,以便我可以很容易地使用
PHP中的CodeIgniter实现Google帐户登录.
下载
LightOpenID.创建login.PHP并粘贴以下代码
原文链接:https://www.f2er.com/php/131367.html<?PHP require_once 'openid.PHP'; $openid = new LightOpenID("my-domain.com"); if ($openid->mode) { if ($openid->mode == 'cancel') { echo "User has canceled authentication !"; } elseif ($openid->validate()) { $data = $openid->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."; }
<?PHP require_once 'openid.PHP'; $openid = new LightOpenID("my-domain.com"); $openid->identity = 'https://www.google.com/accounts/o8/id'; $openid->required = array( 'namePerson/first','namePerson/last','contact/email',); $openid->returnUrl = 'http://my-domain.com/login.PHP' ?> <a href="<?PHP echo $openid->authUrl() ?>">Login with Google</a>
这就是你所做的一切.代码取自Google Login with LightOpenID