summaryrefslogtreecommitdiff
path: root/plugins/BitlyUrl
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/BitlyUrl')
-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;
}
}
+