. * * @category Plugin * @package StatusNet * @author Craig Andrews * @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.'/plugins/UrlShortener/UrlShortenerPlugin.php'; class LilUrlPlugin extends UrlShortenerPlugin { public $serviceUrl; function onInitializePlugin(){ parent::onInitializePlugin(); if(!isset($this->serviceUrl)){ throw new Exception("must specify a serviceUrl"); } } 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']); } } }