JanRain PHP OpenID: how to check if AX provider supports programmatically?

Well, my problem is that some providers support SREG, and some only support AX. I need to know how I can ask the provider which methods they support. I tried to look at the documentation here http://openidenabled.com/files/php-openid/docs/2.1.3/ , but I did not see anything.

+3
source share
2 answers

Faced with a similar problem.

This code should help you.

So if


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
}

this will help you diagnose what data will come in, SREG or attribute exchange

+2
source

Source: https://habr.com/ru/post/1737307/


All Articles