当前位置: 首页>>代码示例>>PHP>>正文


PHP Auth_Yadis_Yadis::discover方法代码示例

本文整理汇总了PHP中Auth_Yadis_Yadis::discover方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth_Yadis_Yadis::discover方法的具体用法?PHP Auth_Yadis_Yadis::discover怎么用?PHP Auth_Yadis_Yadis::discover使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Auth_Yadis_Yadis的用法示例。


在下文中一共展示了Auth_Yadis_Yadis::discover方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fromYadisURL

 /**
  * Create an instance from URL
  *
  * Constructs an OMB_Yadis_XRDS object from a given URL. A full Yadis
  * discovery is performed on the URL and the XRDS is parsed.
  * Throws an OMB_InvalidYadisException when no Yadis is discovered or the
  * detected XRDS file is broken.
  *
  * @param string                 $url     The URL on which Yadis discovery
  *                                        should be performed on
  * @param Auth_Yadis_HTTPFetcher $fetcher A fetcher used to get HTTP
  *                                        resources
  *
  * @access public
  *
  * @return OMB_Yadis_XRDS The initialized object representing the given
  *                        resource
  */
 public static function fromYadisURL($url, $fetcher)
 {
     /* Perform a Yadis discovery. */
     $yadis = Auth_Yadis_Yadis::discover($url, $fetcher);
     if ($yadis->failed) {
         throw new OMB_InvalidYadisException($url);
     }
     /* Parse the XRDS file. */
     $xrds = OMB_Yadis_XRDS::parseXRDS($yadis->response_text);
     if ($xrds === null) {
         throw new OMB_InvalidYadisException($url);
     }
     $xrds->fetcher = $fetcher;
     return $xrds;
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:33,代码来源:omb_yadis_xrds.php

示例2: runTest

 function runTest()
 {
     $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
     $y = Auth_Yadis_Yadis::discover($this->input_url, $fetcher);
     $this->assertTrue($y !== null);
     // Compare parts of returned Yadis object to expected URLs.
     $this->assertEquals($this->redir_uri, $y->normalized_uri, "tried {$this->input_url}");
     if ($this->xrds_uri) {
         $this->assertEquals($this->xrds_uri, $y->xrds_uri);
         // Compare contents of actual HTTP GET with that of Yadis
         // response.
         $f = Auth_Yadis_Yadis::getHTTPFetcher();
         $http_response = $f->get($this->xrds_uri);
         $this->assertEquals($http_response->body, $y->response_text);
     } else {
         $this->assertTrue($y->xrds_uri === null);
     }
 }
开发者ID:openid,项目名称:php-openid,代码行数:18,代码来源:Yadis.php

示例3: openid_server_update_delegation_info

/**
 * Discover and cache OpenID services for a user's delegate OpenID.
 *
 * @param int $userid user ID
 * @url string URL to discover.  If not provided, user's current delegate will be used
 * @return bool true if successful
 */
function openid_server_update_delegation_info($userid, $url = null)
{
    if (empty($url)) {
        $url = get_usermeta($userid, 'openid_delegate');
    }
    if (empty($url)) {
        return false;
    }
    $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
    $discoveryResult = Auth_Yadis_Yadis::discover($url, $fetcher);
    $endpoints = Auth_OpenID_ServiceEndpoint::fromDiscoveryResult($discoveryResult);
    $services = array();
    if (!empty($endpoints)) {
        foreach ($endpoints as $endpoint) {
            $service = array('Type' => array(), 'URI' => $endpoint->server_url);
            foreach ($endpoint->type_uris as $type) {
                $service['Type'][] = array('content' => $type);
                if ($type == Auth_OpenID_TYPE_2_0_IDP) {
                    $service['LocalID'] = Auth_OpenID_IDENTIFIER_SELECT;
                } else {
                    if ($type == Auth_OpenID_TYPE_2_0) {
                        $service['LocalID'] = $endpoint->local_id;
                    } else {
                        if (in_array($type, array(Auth_OpenID_TYPE_1_0, Auth_OpenID_TYPE_1_1, Auth_OpenID_TYPE_1_2))) {
                            $service['openid:Delegate'] = $endpoint->local_id;
                        }
                    }
                }
            }
            $services[] = $service;
        }
    }
    if (empty($services)) {
        // resort to checking for HTML links
        $response = $fetcher->get($url);
        $html_content = $response->body;
        $p = new Auth_OpenID_Parse();
        $link_attrs = $p->parseLinkAttrs($html_content);
        // check HTML for OpenID2
        $server_url = $p->findFirstHref($link_attrs, 'openid2.provider');
        if ($server_url !== null) {
            $openid_url = $p->findFirstHref($link_attrs, 'openid2.local_id');
            if ($openid_url == null) {
                $openid_url = $url;
            }
            $services[] = array('Type' => array(array('content' => Auth_OpenID_Type_1_1)), 'URI' => $server_url, 'LocalID' => $openid_url);
        }
        // check HTML for OpenID1
        $server_url = $p->findFirstHref($link_attrs, 'openid.server');
        if ($server_url !== null) {
            $openid_url = $p->findFirstHref($link_attrs, 'openid.delegate');
            if ($openid_url == null) {
                $openid_url = $url;
            }
            $services[] = array('Type' => array(array('content' => Auth_OpenID_Type_2_0)), 'URI' => $server_url, 'openid:Delegate' => $openid_url);
        }
    }
    if (empty($services)) {
        return false;
    }
    update_usermeta($userid, 'openid_delegate', $url);
    update_usermeta($userid, 'openid_delegate_services', $services);
    return true;
}
开发者ID:alx,项目名称:pressid,代码行数:71,代码来源:server.php

示例4: test_blank_content_type

 function test_blank_content_type()
 {
     $fetcher = new BlankContentTypeFetcher();
     $result = Auth_Yadis_Yadis::discover("http://bogus", $fetcher);
     $this->assertEquals("", $result->content_type);
 }
开发者ID:Stony-Brook-University,项目名称:doitsbu,代码行数:6,代码来源:Discover_Yadis.php

示例5: remoteSubscription

 function remoteSubscription()
 {
     $user = $this->getUser();
     if (!$user) {
         $this->showForm(_('No such user.'));
         return;
     }
     $this->profile_url = $this->trimmed('profile_url');
     if (!$this->profile_url) {
         $this->showForm(_('No such user.'));
         return;
     }
     if (!Validate::uri($this->profile_url, array('allowed_schemes' => array('http', 'https')))) {
         $this->showForm(_('Invalid profile URL (bad format)'));
         return;
     }
     $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
     $yadis = Auth_Yadis_Yadis::discover($this->profile_url, $fetcher);
     if (!$yadis || $yadis->failed) {
         $this->showForm(_('Not a valid profile URL (no YADIS document).'));
         return;
     }
     # XXX: a little liberal for sites that accidentally put whitespace before the xml declaration
     $xrds =& Auth_Yadis_XRDS::parseXRDS(trim($yadis->response_text));
     if (!$xrds) {
         $this->showForm(_('Not a valid profile URL (no XRDS defined).'));
         return;
     }
     $omb = $this->getOmb($xrds);
     if (!$omb) {
         $this->showForm(_('Not a valid profile URL (incorrect services).'));
         return;
     }
     if (omb_service_uri($omb[OAUTH_ENDPOINT_REQUEST]) == common_local_url('requesttoken')) {
         $this->showForm(_('That\'s a local profile! Login to subscribe.'));
         return;
     }
     if (User::staticGet('uri', omb_local_id($omb[OAUTH_ENDPOINT_REQUEST]))) {
         $this->showForm(_('That\'s a local profile! Login to subscribe.'));
         return;
     }
     list($token, $secret) = $this->requestToken($omb);
     if (!$token || !$secret) {
         $this->showForm(_('Couldn\'t get a request token.'));
         return;
     }
     $this->requestAuthorization($user, $omb, $token, $secret);
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:48,代码来源:remotesubscribe.php

示例6: validate

 /**
  * Check if user supplied URL is a valid OpenID and
  * get the URL provider from it.
  * 
  * @param string $identifier user supplied OpenID identifier
  * @return string
  */
 public function validate($identifier)
 {
     $oldIdentifier = get_option('openid_delegation_url');
     $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
     $response = Auth_Yadis_Yadis::discover($identifier, $fetcher);
     list($normalized_identifier, $endpoints) = Auth_OpenID_discover($identifier, $fetcher);
     if (!empty($identifier) && empty($endpoints)) {
         add_settings_error('openid_delegation_url', 'error', sprintf(__('No OpenID services discovered for %s.', 'openid-delegation'), $identifier));
         return $oldIdentifier;
     }
     update_option('openid_delegation_provider', $endpoints[0]->server_url);
     if (!empty($response->xrds_uri)) {
         update_option('openid_delegation_xrds_location', $response->xrds_uri);
     }
     return $normalized_identifier;
 }
开发者ID:rodrigoprimo,项目名称:wordpress-openid-delegation,代码行数:23,代码来源:openid-delegation.php

示例7: Auth_OpenID_discoverWithYadis

function Auth_OpenID_discoverWithYadis($uri, &$fetcher)
{
    // Discover OpenID services for a URI. Tries Yadis and falls back
    // on old-style <link rel='...'> discovery if Yadis fails.
    // Might raise a yadis.discover.DiscoveryFailure if no document
    // came back for that URI at all.  I don't think falling back to
    // OpenID 1.0 discovery on the same URL will help, so don't bother
    // to catch it.
    $openid_services = array();
    $response = Auth_Yadis_Yadis::discover($uri, $fetcher);
    $yadis_url = $response->normalized_uri;
    $yadis_services = array();
    if ($response->isFailure()) {
        return array($uri, array());
    }
    $xrds =& Auth_Yadis_XRDS::parseXRDS($response->response_text);
    if ($xrds) {
        $yadis_services = $xrds->services(array('filter_MatchesAnyOpenIDType'));
    }
    if (!$yadis_services) {
        if ($response->isXRDS()) {
            return Auth_OpenID_discoverWithoutYadis($uri, $fetcher);
        }
        // Try to parse the response as HTML to get OpenID 1.0/1.1
        // <link rel="...">
        $openid_services = Auth_OpenID_ServiceEndpoint::fromHTML($yadis_url, $response->response_text);
    } else {
        $openid_services = Auth_OpenID_makeOpenIDEndpoints($yadis_url, $yadis_services);
    }
    $openid_services = Auth_OpenID_getOPOrUserServices($openid_services);
    return array($yadis_url, $openid_services);
}
开发者ID:ramziammar,项目名称:websites,代码行数:32,代码来源:Discover.php

示例8: runTest

 function runTest()
 {
     if ($this->expected === null) {
         $result = Auth_Yadis_Yadis::discover($this->input_url, $this->fetcher);
         $this->assertTrue($result->isFailure());
     } else {
         $result = Auth_Yadis_Yadis::discover($this->input_url, $this->fetcher);
         if ($result === null) {
             $this->fail("Discovery result was null");
             return;
         }
         $this->assertEquals($this->input_url, $result->request_uri);
         $msg = 'Identity URL mismatch: actual = %s, expected = %s';
         $msg = sprintf($msg, $result->normalized_uri, $this->expected->uri);
         $this->assertEquals($this->expected->uri, $result->normalized_uri, $msg);
         $msg = 'Content mismatch: actual = %s, expected = %s';
         $msg = sprintf($msg, $result->response_text, $this->expected->body);
         $this->assertEquals($this->expected->body, $result->response_text, $msg);
         $this->assertEquals($this->expected->xrds_uri, $result->xrds_uri);
         $this->assertEquals($this->expected->content_type, $result->content_type);
     }
 }
开发者ID:Jobava,项目名称:diacritice-meta-repo,代码行数:22,代码来源:Discover_Yadis.php

示例9: Auth_Yadis_Email_getServices

/**
 * Perform XRDS discovery at the specified URI for any EAUT Services.
 */
function Auth_Yadis_Email_getServices($uri, $fetcher)
{
    $uri = Auth_OpenID::normalizeUrl($uri);
    $response = Auth_Yadis_Yadis::discover($uri, $fetcher);
    if ($response->isXRDS()) {
        $xrds =& Auth_Yadis_XRDS::parseXRDS($response->response_text);
        if ($xrds) {
            return $xrds->services(array('filter_MatchesAnyEmailType'));
        }
    }
}
开发者ID:alx,项目名称:pressid,代码行数:14,代码来源:Email.php

示例10: get_remote_xrds

function get_remote_xrds($at_url)
{
    global $request;
    $wp_plugins = "wp-plugins" . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR . "enabled";
    $path = plugin_path() . $wp_plugins . DIRECTORY_SEPARATOR . 'wp-openid' . DIRECTORY_SEPARATOR;
    add_include_path($path);
    require_once "Auth/Yadis/Yadis.php";
    $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
    $yadis = Auth_Yadis_Yadis::discover($at_url, $fetcher);
    if (!$yadis || $yadis->failed) {
        trigger_error("Sorry but the Yadis doc was not found at the profile URL", E_USER_ERROR);
    }
    $xrds =& Auth_Yadis_XRDS::parseXRDS($yadis->response_text);
    if (!$xrds) {
        trigger_error("Sorry but the XRDS data was not found in the Yadis doc", E_USER_ERROR);
    }
    $yadis_services = $xrds->services(array('filter_MatchesAnyOMBType'));
    foreach ($yadis_services as $service) {
        $type_uris = $service->getTypes();
        $uris = $service->getURIs();
        if ($type_uris && $uris) {
            foreach ($uris as $uri) {
                $xrd = xrdends($uri, $xrds);
                $ends = $xrd->services(array('filter_MatchesAnyOMBType'));
                foreach ($ends as $serv) {
                    $typ = $serv->getTypes();
                    global $omb_services;
                    $end = "";
                    foreach ($typ as $t) {
                        if (in_array($t, $omb_services)) {
                            $end = $t;
                        }
                        if ($t == OAUTH_VERSION . '/endpoint/request') {
                            $data = $serv->getElements('xrd:LocalID');
                            $localid = $serv->parser->content($data[0]);
                        }
                    }
                    $req = $serv->getURIs();
                    $endpoints[$end] = $req[0];
                }
            }
        }
    }
    return array($localid, $endpoints);
}
开发者ID:Br3nda,项目名称:openmicroblogger,代码行数:45,代码来源:omb.php


注:本文中的Auth_Yadis_Yadis::discover方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。