JanRain PHP OpenID:如何检查提供程序是否以编程方式支持AX?

时间:2010-03-17 10:13:23

标签: php openid janrain sreg attribute-exchange

好的,我的问题是有些提供商支持SREG而有些支持只有AX我需要知道我可以向提供商请求他们支持哪些方法..我试着查看这里的文档http://openidenabled.com/files/php-openid/docs/2.1.3/但我没有看到任何东西。

2 个答案:

答案 0 :(得分:2)

面临类似的问题。

以下代码可以为您提供帮助。

所以,如果


function getReturnTo() {
    return sprintf("%s://%s:%s%s/finish_auth.php",
                   getScheme(), $_SERVER['SERVER_NAME'],
                   $_SERVER['SERVER_PORT'],
                   dirname($_SERVER['PHP_SELF']));
}

function &getConsumer() {
    /**
     * Create a consumer object using the store object created
     * earlier.
     */
    $store = getStore();
    $consumer =& new Auth_OpenID_Consumer($store);
    return $consumer;
}

$consumer = getConsumer();

$return_to = getReturnTo();
$response = $consumer->complete($return_to);

$sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);

$ax = new Auth_OpenID_AX_FetchResponse();
$obj = $ax->fromSuccessResponse($response);

if($sreg)
{
   //sreg is supported, start creating the sreg data array.
}
elseif($obj)
{
   // attribute exchange supported. fetch details here
}

这将有助于您诊断即将推出的数据,SREG或Atribute Exchange

答案 1 :(得分:0)

感谢这个问题和answer at another question,我创建了一个以对我有意义的方式使用此代码的示例,并且希望也能为您服务。这是http://gitorious.org/openid-examples/openid-examples