3

わかりました、私の問題は、一部のプロバイダーが SREG をサポートし、一部のプロバイダーが AX のみをサポートしていることです。プロバイダーがサポートするメソッドをプロバイダーに要求できる方法を知る必要があります。 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またはAtributeExchangeのどちらのデータが送信されるかを診断するのに役立ちます

于 2010-03-17T10:35:25.330 に答える