diff options
author | Evan Prodromou <evan@status.net> | 2009-09-15 17:16:35 -0400 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2009-09-15 17:16:35 -0400 |
commit | 13147143fc830e81b80ae86bf4cc4f745ce04381 (patch) | |
tree | 7197e7c3437e028a1bc2358f38ac3964cf3fe6e9 /plugins/LilUrl/LilUrlPlugin.php | |
parent | e559f82e86c495abdc4cf5fff3d8c6279a808354 (diff) | |
parent | 4081ed79b02fd06f7c347803478e1f835311c2ab (diff) |
Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x
Diffstat (limited to 'plugins/LilUrl/LilUrlPlugin.php')
-rw-r--r-- | plugins/LilUrl/LilUrlPlugin.php | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/plugins/LilUrl/LilUrlPlugin.php b/plugins/LilUrl/LilUrlPlugin.php new file mode 100644 index 000000000..7665b6c1e --- /dev/null +++ b/plugins/LilUrl/LilUrlPlugin.php @@ -0,0 +1,64 @@ +<?php +/** + * StatusNet, the distributed open-source microblogging tool + * + * Plugin to push RSS/Atom updates to a PubSubHubBub hub + * + * PHP version 5 + * + * LICENCE: This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @category Plugin + * @package StatusNet + * @author Craig Andrews <candrews@integralblue.com> + * @copyright 2009 Craig Andrews http://candrews.integralblue.com + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +require_once(INSTALLDIR.'/lib/Shorturl_api.php'); + +class LilUrlPlugin extends Plugin +{ + function __construct() + { + parent::__construct(); + } + + function onInitializePlugin(){ + $this->registerUrlShortener( + 'ur1.ca', + array('freeService'=>true), + array('LilUrl',array('http://ur1.ca/')) + ); + } +} + +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; + $x = $y->body->p[0]->a->attributes(); + if (isset($x['href'])) return $x['href']; + return $url; + } +} |