我在我的站點中實現了登錄。我想實現登錄有點如何在stackoverflow中完成。但只有一個選項的Gmail。 1)用戶必須選擇登錄類型的Gmail 2)他必須輸入自己的Gmail用戶名和密碼 3)他必須redirecred回到現場使用Gmail登錄網站
我在這..Any幫助PLZ很新
我在我的站點中實現了登錄。我想實現登錄有點如何在stackoverflow中完成。但只有一個選項的Gmail。 1)用戶必須選擇登錄類型的Gmail 2)他必須輸入自己的Gmail用戶名和密碼 3)他必須redirecred回到現場使用Gmail登錄網站
我在這..Any幫助PLZ很新
這是很容易與LightOpenID完成。他們有an example這個用例。
<?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 = 'https://www.google.com/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的系統):
www
文件夾映射到我的服務器。[email protected]:~/www$ wget http://gitorious.org/lightopenid/lightopenid/archive-tarball/master
--2011-02-02 13:21:30-- http://gitorious.org/lightopenid/lightopenid/archive-tarball/master
Resolving gitorious.org... 87.238.52.168
Connecting to gitorious.org|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]
[email protected]:~/www$ tar xfz master
[email protected]:~/www$ google-chrome http://localhost/lightopenid-lightopenid/example-google.php
Created new window in existing browser session.
非常感謝......你可以舉個簡單的例子... – 2011-02-02 12:09:14
這是一個完整的簡單例子;)。當你下載tarball時,你可以運行這個例子=> http://gitorious.org/lightopenid/lightopenid/archive-tarball/master – Alfred 2011-02-02 12:17:33
它是通過OpenID進行身份驗證的。閱讀本http://code.google.com/apis/accounts/docs/OpenID.html
這個環節上其名爲OpenID的外觀http://technofriends.in/2008/11/10/what-is-openid-and-how-to-use-your-gmail-account-as-openid/ – 2011-02-02 12:00:28