我一直在玩JanRain OpenID PHP庫,主要跟隨a tutorial I found on ZendZone。如何在不請求SReg字段的情況下通過OpenID區分/識別用戶?
如何區分用戶 - 尤其是Google用戶,他們最終都使用相同的OpenID URL https://www.google.com/accounts/o8/id?
基本上,我可以檢測到他們有一個OpenID帳戶...他們已經成功驗證...但我的應用程序仍然不知道他們是誰;只有他們認證。
爲了區分用戶,本教程使用「簡單註冊請求」來請求用戶的OpenID提供商的電子郵件 - 然後使用電子郵件地址查看這是否是返回用戶。
它不適合我,apparently won't work with some providers所以我很興奮,當我偶然發現一個函數getDisplayIdentifier
。
require_once "Auth/OpenID/Consumer.php";
require_once "Auth/OpenID/FileStore.php";
// create file storage area for OpenID data
$store = new Auth_OpenID_FileStore('/wtv');
$consumer = new Auth_OpenID_Consumer($store);
$oid_response = $consumer->complete("http://example.com/oir_return");
if ($oid_response->status == Auth_OpenID_SUCCESS) {
$hopefullyUniqueUserID = $oid_response->getDisplayIdentifier(); // I assumed this would be a relatively permanent way to identify the user...
// I was wrong.
}
不幸的是,幾個小時後getDisplayIdentifier
返回的值發生了變化。
請仔細閱讀說明書。 'https:// www.google.com/accounts/o8/id'是用戶提供的標識符,用戶不一定聲稱擁有它,其目的可能只是引導用戶選擇標識符,因爲與谷歌案。 – Artefacto 2010-07-03 11:25:01