示例#1
0
 /**
  * undocumented function
  *
  * @param string $url
  * @return array
  * @link http://www.oexchange.org/spec/#discovery-page
  */
 public static function page($url)
 {
     $htmlDocument = new DOMDocument();
     $loaded = @$htmlDocument->loadHTML(self::_retrieve($url));
     if (!$loaded) {
         throw new OExchange_Exception("Failed to load {$url}");
     }
     $xpath = new DOMXpath($htmlDocument);
     $expression = "/html/head/link[@rel='" . self::OEXCHANGE_RELATED_TARGET_REL . "']";
     $links = $xpath->query($expression);
     $targets = array();
     foreach ($links as $link) {
         $serviceXRD = XRD_Document::fromString(self::_retrieve($link->getAttribute('href')));
         $targets[] = OExchange_Target::fromXRD($serviceXRD);
     }
     return $targets;
 }
示例#2
0
 /**
  * undocumented function
  *
  * @param XRD_Document $xrd 
  * @return OExchange_Service
  */
 public static function fromXRD(XRD_Document $xrd)
 {
     $service = new OExchange_Target();
     $service->subject = $xrd->subject;
     $iconLink = $xrd->firstLinkByRel('icon');
     $service->icon = $iconLink->href;
     $service->iconType = $iconLink->type;
     $icon32Link = $xrd->firstLinkByRel('icon32');
     $service->icon32 = $icon32Link->href;
     $service->icon32Type = $icon32Link->type;
     $offerLink = $xrd->firstLinkByRel(self::OEXCHANGE_OFFER_REL);
     $service->offer = $offerLink->href;
     $service->offerType = $offerLink->type;
     $propertyMap = array('title' => self::OEXCHANGE_TITLE_PROPERTY_TYPE, 'vendor' => self::OEXCHANGE_VENDOR_PROPERTY_TYPE, 'name' => self::OEXCHANGE_NAME_PROPERTY_TYPE, 'prompt' => self::OEXCHANGE_PROMPT_PROPERTY_TYPE);
     foreach ($propertyMap as $propertyName => $propertyType) {
         $service->{$propertyName} = $xrd->firstPropertyByType($propertyType)->value;
     }
     return $service;
 }