JanRain PHP OpenID:如何检查提供程序是否以编程方式支持AX?(JanRain PHP OpenID: How to check if a provider supports AX programmatically?)
好吧,我的问题是有些提供商支持SREG而有些支持只有AX我需要知道我是如何向提供商请求他们支持哪些方法..我试着查看这里的文档http://openidenabled.com/ files / php-openid / docs / 2.1.3 /但我什么也没看到。
Ok, my problem is that some providers support SREG and some support only AX I need to know how it is that I can request from the provider which methods they support.. I tried looking through the documentation here http://openidenabled.com/files/php-openid/docs/2.1.3/ but I didn't see anything.
最满意答案
面临类似的问题。
以下代码应该可以帮助您。
因此,如果
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
Faced similar problem.
The below 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 which data is coming, SREG or Atribute Exchange
更多推荐
发布评论