3 * Abstract class for LRDD discovery methods
5 * Objects that extend this class can retrieve an array of
6 * resource descriptor links for the URI. The array consists
7 * of XML_XRD_Element_Link elements.
11 * @author James Walker <james@status.net>
12 * @copyright 2010 StatusNet, Inc.
13 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
14 * @link http://status.net/
16 abstract class LRDDMethod
18 protected $xrd = null;
20 public function __construct() {
21 $this->xrd = new XML_XRD();
25 * Discover interesting info about the URI
27 * @param string $uri URI to inquire about
29 * @return array of XML_XRD_Element_Link elements to discovered resource descriptors
31 abstract public function discover($uri);
33 protected function fetchUrl($url, $method=HTTPClient::METHOD_GET)
35 $client = new HTTPClient();
37 // GAAHHH, this method sucks! How about we make a better HTTPClient interface?
39 case HTTPClient::METHOD_GET:
40 $response = $client->get($url);
42 case HTTPClient::METHOD_HEAD:
43 $response = $client->head($url);
46 throw new Exception('Bad HTTP method.');
49 if ($response->getStatus() != 200) {
50 throw new Exception('Unexpected HTTP status code.');