123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- class LilUrlPlugin extends UrlShortenerPlugin
- {
- public $serviceUrl;
- function onInitializePlugin(){
- parent::onInitializePlugin();
- if(!isset($this->serviceUrl)){
-
- throw new Exception(_m('A serviceUrl must be specified.'));
- }
- }
- 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'])) {
- return strval($x['href']);
- }
- }
- function onPluginVersion(&$versions)
- {
- $versions[] = array('name' => sprintf('LilUrl (%s)', $this->shortenerName),
- 'version' => GNUSOCIAL_VERSION,
- 'author' => 'Craig Andrews',
- 'homepage' => 'http://status.net/wiki/Plugin:LilUrl',
- 'rawdescription' =>
-
-
- sprintf(_m('Uses <a href="http://%1$s/">%1$s</a> URL-shortener service.'),
- $this->shortenerName));
- return true;
- }
- }
|