我一直在玩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