Exemplo n.º 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;
 }
Exemplo n.º 2
0
 public function testToXRDDocumentGeneration()
 {
     $target = new OExchange_Target(array('name' => 'CoolService', 'title' => 'A cool service that accepts URLs', 'subject' => 'http://www.example.org/coolservice', 'vendor' => 'Examples Inc', 'prompt' => 'Share to CoolService', 'offer' => 'http://www.example.com/coolservice/offer.php', 'icon' => 'http://www.example.com/assets/icon.png', 'icon32' => 'http://www.example.com/assets/icon32.png'));
     $result = $target->toXRD()->toXML();
     $this->assertXmlStringEqualsXmlFile(TEST_DATA_PATH . '/coolservice.xrd', $result);
 }