gnu-social/plugins/LRDD/lib/lrddmethod.php
Mikael Nordfeldth a0e107f17f Implemented WebFinger and replaced our XRD with PEAR XML_XRD
New plugins:
* LRDD
    LRDD implements client-side RFC6415 and RFC7033 resource descriptor
    discovery procedures. I.e. LRDD, host-meta and WebFinger stuff.

    OStatus and OpenID now depend on the LRDD plugin (XML_XRD).

* WebFinger
    This plugin implements the server-side of RFC6415 and RFC7033. Note:
    WebFinger technically doesn't handle XRD, but we serve both that and
    JRD (JSON Resource Descriptor), depending on Accept header and one
    ugly hack to check for old StatusNet installations.

    WebFinger depends on LRDD.

We might make this even prettier by using Net_WebFinger, but it is not
currently RFC7033 compliant (no /.well-known/webfinger resource GETs).

Disabling the WebFinger plugin would effectively render your site non-
federated (which might be desired on a private site).

Disabling the LRDD plugin would make your site unable to do modern web
URI lookups (making life just a little bit harder).
2013-09-30 22:04:52 +02:00

56 lines
1.5 KiB
PHP

<?php
/**
* Abstract class for LRDD discovery methods
*
* Objects that extend this class can retrieve an array of
* resource descriptor links for the URI. The array consists
* of XML_XRD_Element_Link elements.
*
* @category Discovery
* @package StatusNet
* @author James Walker <james@status.net>
* @copyright 2010 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
abstract class LRDDMethod
{
protected $xrd = null;
public function __construct() {
$this->xrd = new XML_XRD();
}
/**
* Discover interesting info about the URI
*
* @param string $uri URI to inquire about
*
* @return array of XML_XRD_Element_Link elements to discovered resource descriptors
*/
abstract public function discover($uri);
protected function fetchUrl($url, $method=HTTPClient::METHOD_GET)
{
$client = new HTTPClient();
// GAAHHH, this method sucks! How about we make a better HTTPClient interface?
switch ($method) {
case HTTPClient::METHOD_GET:
$response = $client->get($url);
break;
case HTTPClient::METHOD_HEAD:
$response = $client->head($url);
break;
default:
throw new Exception('Bad HTTP method.');
}
if ($response->getStatus() != 200) {
throw new Exception('Unexpected HTTP status code.');
}
return $response;
}
}