summaryrefslogtreecommitdiff
path: root/plugins/PtitUrl
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/PtitUrl
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/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;
}
}
+