4 * Code for using a proxy XRI resolver.
7 require_once 'Auth/Yadis/XRDS.php';
8 require_once 'Auth/Yadis/XRI.php';
10 class Auth_Yadis_ProxyResolver {
11 function Auth_Yadis_ProxyResolver($fetcher, $proxy_url = null)
13 $this->fetcher = $fetcher;
14 $this->proxy_url = $proxy_url;
15 if (!$this->proxy_url) {
16 $this->proxy_url = Auth_Yadis_getDefaultProxy();
20 function queryURL($xri, $service_type = null)
22 // trim off the xri:// prefix
23 $qxri = substr(Auth_Yadis_toURINormal($xri), 6);
24 $hxri = $this->proxy_url . $qxri;
26 '_xrd_r' => 'application/xrds+xml'
30 $args['_xrd_t'] = $service_type;
32 // Don't perform service endpoint selection.
33 $args['_xrd_r'] .= ';sep=false';
36 $query = Auth_Yadis_XRIAppendArgs($hxri, $args);
40 function query($xri, $service_types, $filters = array())
44 foreach ($service_types as $service_type) {
45 $url = $this->queryURL($xri, $service_type);
46 $response = $this->fetcher->get($url);
47 if ($response->status != 200 and $response->status != 206) {
50 $xrds = Auth_Yadis_XRDS::parseXRDS($response->body);
54 $canonicalID = Auth_Yadis_getCanonicalID($xri,
57 if ($canonicalID === false) {
61 $some_services = $xrds->services($filters);
62 $services = array_merge($services, $some_services);
64 // * If we do get hits for multiple service_types, we're
65 // almost certainly going to have duplicated service
66 // entries and broken priority ordering.
68 return array($canonicalID, $services);