使用Gmail登录网站

编程入门 行业动态 更新时间:2024-10-09 04:18:11
本文介绍了使用Gmail登录网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我要在我的网站上实施一个登录.我想以某种方式实现登录,这是在stackoverflow中完成的.但是只有一个gmail选项. 1)用户必须选择登录类型为gmail 2)他必须输入自己的gmail用户名和密码 3)他必须重新分配回站点

I am implemint a login in my site.I want to implement the login somewhat how it is done in stackoverflow.But with only one option of gmail. 1)The user must have chose login type as gmail 2)He must enter his gmail username and password 3)He must be redirecred back to site

我在这方面是个新手..请帮助pz

i am very new in this ..Any help plz

推荐答案

使用 LightOpenID 非常容易完成.考虑到该用例,他们有一个示例.

This is very easy to accomplish with LightOpenID. They have an example available with that use case in mind.

<?php # Logging in with Google accounts requires setting special identity, so this example shows how to do it. require 'openid.php'; try { $openid = new LightOpenID; if(!$openid->mode) { if(isset($_GET['login'])) { $openid->identity = 'www.google/accounts/o8/id'; header('Location: ' . $openid->authUrl()); } ?> <form action="?login" method="post"> <button>Login with Google</button> </form> <?php } elseif($openid->mode == 'cancel') { echo 'User has canceled authentication!'; } else { echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.'; } } catch(ErrorException $e) { echo $e->getMessage(); }

让您启动并运行起来真的很简单(我假设* nix像系统一样):

To get you up and running is really simple(I assume *nix like system):

  • 我有www文件夹映射到我的服务器.
  • 我假设您有在本地主机上运行的服务器.
  • 我认为您已经安装了google-chrome.
  • I have www folder mapped to my server.
  • I assume you have server it running on localhost.
  • I assume you have google-chrome installed.
alfred@alfred-laptop:~/www$ wget gitorious/lightopenid/lightopenid/archive-tarball/master --2011-02-02 13:21:30-- gitorious/lightopenid/lightopenid/archive-tarball/master Resolving gitorious... 87.238.52.168 Connecting to gitorious|87.238.52.168|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 17104 (17K) [application/x-gzip] Saving to: `master' 100%[======================================>] 17,104 --.-K/s in 0.04s 2011-02-02 13:21:30 (386 KB/s) - `master' saved [17104/17104] alfred@alfred-laptop:~/www$ tar xfz master alfred@alfred-laptop:~/www$ google-chrome localhost/lightopenid-lightopenid/example-google.php Created new window in existing browser session.

更多推荐

使用Gmail登录网站

本文发布于:2023-11-09 23:24:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573728.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网站   Gmail

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!