diff options
author | Craig Andrews <candrews@integralblue.com> | 2009-11-11 14:02:57 -0500 |
---|---|---|
committer | Craig Andrews <candrews@integralblue.com> | 2009-11-11 14:04:44 -0500 |
commit | 014d6b1d19b6ae5de8d87f055397993f80579f74 (patch) | |
tree | 55faca777c7ef1f8576b21f98dc4e3f74e99ac4d /plugins/TightUrl | |
parent | 086759f32ab6d2c5aadecb57941e7e14015b8bd6 (diff) |
Redid how URL shorteners work. This way is much more like how Evan wants events to work (and more like how the rest of SN works).
Diffstat (limited to 'plugins/TightUrl')
-rw-r--r-- | plugins/TightUrl/TightUrlPlugin.php | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/plugins/TightUrl/TightUrlPlugin.php b/plugins/TightUrl/TightUrlPlugin.php index 48efb355f..56414c8c8 100644 --- a/plugins/TightUrl/TightUrlPlugin.php +++ b/plugins/TightUrl/TightUrlPlugin.php @@ -31,32 +31,27 @@ if (!defined('STATUSNET')) { exit(1); } -class TightUrlPlugin extends Plugin +require_once INSTALLDIR.'/plugins/UrlShortener/UrlShortenerPlugin.php'; + +class TightUrlPlugin extends UrlShortenerPlugin { - function __construct() - { - parent::__construct(); - } + public $serviceUrl; function onInitializePlugin(){ - $this->registerUrlShortener( - '2tu.us', - array('freeService'=>true), - array('TightUrl',array('http://2tu.us/?save=y&url=')) - ); + parent::onInitializePlugin(); + if(!isset($this->serviceUrl)){ + throw new Exception("must specify a serviceUrl"); + } } -} -class TightUrl extends ShortUrlApi -{ - protected function shorten_imp($url) { - $response = $this->http_get($url); - if (!$response) return $url; + protected function shorten($url) + { + $response = $this->http_get(sprintf($this->serviceUrl,urlencode($url))); + if (!$response) return; $response = $this->tidy($response); $y = @simplexml_load_string($response); - if (!isset($y->body)) return $url; + if (!isset($y->body)) return; $xml = $y->body->p[0]->code[0]->a->attributes(); if (isset($xml['href'])) return $xml['href']; - return $url; } } |