diff options
author | Evan Prodromou <evan@status.net> | 2009-11-17 08:04:14 -0500 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2009-11-17 08:04:14 -0500 |
commit | bac2d80c919a78d5cafd57f712872a90cda04847 (patch) | |
tree | d2df10a582edc0bf9e043f1c764953a290927678 /plugins/TightUrl/TightUrlPlugin.php | |
parent | 9a1a83e8ebe5ad39838e6363f1537a1a5232b9cb (diff) | |
parent | 6a1afda259c5223449f679a64f932e36df5ebe39 (diff) |
Merge branch '0.9.x' into adminpanel
Conflicts:
classes/User.php
Diffstat (limited to 'plugins/TightUrl/TightUrlPlugin.php')
-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; } } |