make some of the Webfinger magic strings constants

This commit is contained in:
Evan Prodromou 2010-02-21 21:36:36 -05:00
parent 37179a91d5
commit fde64ddf26

View File

@ -32,11 +32,16 @@ define('WEBFINGER_SERVICE_REL_VALUE', 'lrdd');
/** /**
* Implement the webfinger protocol. * Implement the webfinger protocol.
*/ */
class Webfinger class Webfinger
{ {
const PROFILEPAGE = 'http://webfinger.net/rel/profile-page';
const UPDATESFROM = 'http://schemas.google.com/g/2010#updates-from';
/** /**
* Perform a webfinger lookup given an account. * Perform a webfinger lookup given an account.
*/ */
public function lookup($id) public function lookup($id)
{ {
$id = $this->normalize($id); $id = $this->normalize($id);
@ -46,7 +51,7 @@ class Webfinger
if (!$links) { if (!$links) {
return false; return false;
} }
$services = array(); $services = array();
foreach ($links as $link) { foreach ($links as $link) {
if ($link['template']) { if ($link['template']) {
@ -64,7 +69,7 @@ class Webfinger
function normalize($id) function normalize($id)
{ {
if (substr($id, 0, 7) == 'acct://') { if (substr($id, 0, 7) == 'acct://') {
return substr($id, 7); return substr($id, 7);
} else if (substr($id, 0, 5) == 'acct:') { } else if (substr($id, 0, 5) == 'acct:') {
return substr($id, 5); return substr($id, 5);
} }
@ -86,7 +91,7 @@ class Webfinger
if ($result->host != $domain) { if ($result->host != $domain) {
return false; return false;
} }
$links = array(); $links = array();
foreach ($result->links as $link) { foreach ($result->links as $link) {
if ($link['rel'] == WEBFINGER_SERVICE_REL_VALUE) { if ($link['rel'] == WEBFINGER_SERVICE_REL_VALUE) {
@ -140,4 +145,3 @@ class Webfinger
} }
} }