3

好的,我的问题是一些提供者支持 SREG 而一些只支持 AX 我需要知道我如何可以从提供者那里请求他们支持哪些方法。我尝试查看这里的文档http://openidenabled.com/ files/php-openid/docs/2.1.3/但我什么也没看到。

4

1 回答 1

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 或属性交换

于 2010-03-17T10:35:25.330 回答