summaryrefslogtreecommitdiff
path: root/plugins/LilUrl
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/LilUrl
parent093857c582a68b39e0d65523d27f25ede7b7fed6 (diff)
parent2147ac510f5489c860a4bebf3ab48a069b89ecfb (diff)
Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x
Diffstat (limited to 'plugins/LilUrl')
-rw-r--r--plugins/LilUrl/LilUrlPlugin.php38
1 files changed, 16 insertions, 22 deletions
diff --git a/plugins/LilUrl/LilUrlPlugin.php b/plugins/LilUrl/LilUrlPlugin.php
index 852253b02..e906751e8 100644
--- a/plugins/LilUrl/LilUrlPlugin.php
+++ b/plugins/LilUrl/LilUrlPlugin.php
@@ -31,37 +31,31 @@ if (!defined('STATUSNET')) {
exit(1);
}
-require_once(INSTALLDIR.'/lib/Shorturl_api.php');
+require_once INSTALLDIR.'/plugins/UrlShortener/UrlShortenerPlugin.php';
-class LilUrlPlugin extends Plugin
+class LilUrlPlugin extends UrlShortenerPlugin
{
- function __construct()
- {
- parent::__construct();
- }
+ public $serviceUrl;
function onInitializePlugin(){
- $this->registerUrlShortener(
- 'ur1.ca',
- array('freeService'=>true),
- array('LilUrl',array('http://ur1.ca/'))
- );
+ parent::onInitializePlugin();
+ if(!isset($this->serviceUrl)){
+ throw new Exception("must specify a serviceUrl");
+ }
}
-}
-class LilUrl extends ShortUrlApi
-{
- protected function shorten_imp($url) {
- $data['longurl'] = $url;
- $response = $this->http_post($data);
- if (!$response) return $url;
- $y = @simplexml_load_string($response);
- if (!isset($y->body)) return $url;
+ protected function shorten($url) {
+ $data = array('longurl' => $url);
+
+ $responseBody = $this->http_post($this->serviceUrl,$data);
+
+ if (!$responseBody) return;
+ $y = @simplexml_load_string($responseBody);
+ if (!isset($y->body)) return;
$x = $y->body->p[0]->a->attributes();
if (isset($x['href'])) {
- common_log(LOG_INFO, __CLASS__ . ": shortened $url to $x[href]");
return $x['href'];
}
- return $url;
}
}
+