/** * Obtains the OpenID services for particular identifier by scanning for link * elements in the returned document. * * Note that this function does not use the YADIS protocol to scan for services. * To use the YADIS protocol, use {@link discovery_get_services()}. * * @param string $url the URL * @return XRDSServices an array of discovered services, or an empty array if no services * are found */ public function discoverByHTMLLinks($url) { $services = new XRDSServices(); $response = $this->request($url); $html = $response->getBody(); $uri = $this->getLinkRel('openid2.provider', $html); $delegate = $this->getLinkRel('openid2.local_id', $html); if ($uri) { $service = array('type' => array('http://specs.openid.net/auth/2.0/signon'), 'uri' => array($uri)); if ($delegate) { $service['localid'] = $delegate; } $services->add($service, false); } $uri = $this->getLinkRel('openid.server', $html); $delegate = $this->getLinkRel('openid.delegate', $html); if ($uri) { $service = array('type' => array('http://openid.net/signon/1.0'), 'uri' => array($uri)); if ($delegate) { $service['localid'] = $delegate; } $services->add($service, false); } return $services; }
/** * Parses an XRDS document and returns the discovered services. * * @return XRDSServices the discovered services */ public function parse() { while ($this->reader->read()) { if ($this->reader->nodeType == XMLReader::ELEMENT && strtolower($this->reader->namespaceURI) == strtolower(self::XRD2_NS)) { switch ($this->reader->localName) { case 'Service': $this->services->add($this->parseService()); break; } } } return $this->services; }