summaryrefslogtreecommitdiff
path: root/plugins/BitlyUrl/BitlyUrlPlugin.php
diff options
context:
space:
mode:
authorCraig Andrews <candrews@integralblue.com>2009-11-11 14:02:57 -0500
committerCraig Andrews <candrews@integralblue.com>2009-11-11 14:04:44 -0500
commit014d6b1d19b6ae5de8d87f055397993f80579f74 (patch)
tree55faca777c7ef1f8576b21f98dc4e3f74e99ac4d /plugins/BitlyUrl/BitlyUrlPlugin.php
parent086759f32ab6d2c5aadecb57941e7e14015b8bd6 (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/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;
}
}
+