diff options
author | Zach Copley <zach@status.net> | 2010-02-25 18:57:12 -0800 |
---|---|---|
committer | Zach Copley <zach@status.net> | 2010-02-25 18:57:12 -0800 |
commit | cf61f36e6b313659b3c3fb253972d06c7113f1e8 (patch) | |
tree | 25372b7649e125b2ee149da155f2f9fbae169c2e /plugins/OStatus/lib | |
parent | d8d8d59a03ef3fa12a0ea668b4a2f383f80486dc (diff) | |
parent | 2fa953da22fe932f758882a93106672ab22c1c6d (diff) |
Merge branch 'testing' of gitorious.org:statusnet/mainline into testing
* 'testing' of gitorious.org:statusnet/mainline:
OStatus: pull best-sized avatar image (96x96 if found, otherwise largest, otherwise if none labeled takes the first)
info about discovery in Ostatus_profile::ensureWebfinger()
cache Web responses in Webfinger library
Diffstat (limited to 'plugins/OStatus/lib')
-rw-r--r-- | plugins/OStatus/lib/webfinger.php | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/plugins/OStatus/lib/webfinger.php b/plugins/OStatus/lib/webfinger.php index 8d7040310..4b777c9a0 100644 --- a/plugins/OStatus/lib/webfinger.php +++ b/plugins/OStatus/lib/webfinger.php @@ -81,11 +81,14 @@ class Webfinger function getServiceLinks($domain) { $url = 'http://'. $domain .'/.well-known/host-meta'; + $content = $this->fetchURL($url); + if (empty($content)) { common_log(LOG_DEBUG, 'Error fetching host-meta'); return false; } + $result = XRD::parse($content); // Ensure that the host == domain (spec may include signing later) @@ -119,6 +122,11 @@ class Webfinger function fetchURL($url) { try { + $c = Cache::instance(); + $content = $c->get('webfinger:url:'.$url); + if ($content !== false) { + return $content; + } $client = new HTTPClient(); $response = $client->get($url); } catch (HTTP_Request2_Exception $e) { @@ -129,7 +137,11 @@ class Webfinger return false; } - return $response->getBody(); + $body = $response->getBody(); + + $c->set('webfinger:url:'.$url, $body); + + return $body; } function applyTemplate($template, $id) |