summaryrefslogtreecommitdiff
path: root/plugins/PtitUrl
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/PtitUrl')
-rw-r--r--plugins/PtitUrl/PtitUrlPlugin.php31
1 files changed, 13 insertions, 18 deletions
diff --git a/plugins/PtitUrl/PtitUrlPlugin.php b/plugins/PtitUrl/PtitUrlPlugin.php
index f00d3e2f2..ef453e96d 100644
--- a/plugins/PtitUrl/PtitUrlPlugin.php
+++ b/plugins/PtitUrl/PtitUrlPlugin.php
@@ -30,33 +30,28 @@
if (!defined('STATUSNET')) {
exit(1);
}
+require_once INSTALLDIR.'/plugins/UrlShortener/UrlShortenerPlugin.php';
-class PtitUrlPlugin extends Plugin
+class PtitUrlPlugin extends UrlShortenerPlugin
{
- function __construct()
- {
- parent::__construct();
- }
+ public $serviceUrl;
function onInitializePlugin(){
- $this->registerUrlShortener(
- 'ptiturl.com',
- array(),
- array('PtitUrl',array('http://ptiturl.com/?creer=oui&action=Reduire&url='))
- );
+ parent::onInitializePlugin();
+ if(!isset($this->serviceUrl)){
+ throw new Exception("must specify a serviceUrl");
+ }
}
-}
-class PtitUrl 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->center->table->tr->td->pre->a->attributes();
if (isset($xml['href'])) return $xml['href'];
- return $url;
}
}
+