summaryrefslogtreecommitdiff
path: root/plugins/BitlyUrl/BitlyUrlPlugin.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2009-11-14 17:14:35 +0100
committerEvan Prodromou <evan@status.net>2009-11-14 17:14:35 +0100
commit959d278c347fdf90e0227adc57c0215f5d82404a (patch)
tree16eb3b0155b446ada520566e187b4c47b0b9e76b /plugins/BitlyUrl/BitlyUrlPlugin.php
parent093857c582a68b39e0d65523d27f25ede7b7fed6 (diff)
parent2147ac510f5489c860a4bebf3ab48a069b89ecfb (diff)
Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x
Diffstat (limited to 'plugins/BitlyUrl/BitlyUrlPlugin.php')
-rw-r--r--plugins/BitlyUrl/BitlyUrlPlugin.php31
1 files changed, 12 insertions, 19 deletions
diff --git a/plugins/BitlyUrl/BitlyUrlPlugin.php b/plugins/BitlyUrl/BitlyUrlPlugin.php
index 478ef99d2..65d0f70e6 100644
--- a/plugins/BitlyUrl/BitlyUrlPlugin.php
+++ b/plugins/BitlyUrl/BitlyUrlPlugin.php
@@ -31,31 +31,24 @@ if (!defined('STATUSNET')) {
exit(1);
}
-class BitlyUrlPlugin extends Plugin
+require_once INSTALLDIR.'/plugins/UrlShortener/UrlShortenerPlugin.php';
+
+class BitlyUrlPlugin extends UrlShortenerPlugin
{
- function __construct()
- {
- parent::__construct();
- }
+ public $serviceUrl;
function onInitializePlugin(){
- $this->registerUrlShortener(
- 'bit.ly',
- array(),
- array('BitlyUrl',array('http://bit.ly/api?method=shorten&long_url='))
- );
+ parent::onInitializePlugin();
+ if(!isset($this->serviceUrl)){
+ throw new Exception("must specify a serviceUrl");
+ }
}
-}
-class BitlyUrl extends ShortUrlApi
-{
- protected function shorten_imp($url) {
+ protected function shorten($url) {
$response = $this->http_get($url);
- if(!$response){
- return $url;
- }else{
- return current(json_decode($response)->results)->hashUrl;
- }
+ if(!$response) return;
+ return current(json_decode($response)->results)->hashUrl;
}
}
+