. * * @category Plugin * @package StatusNet * @author Craig Andrews * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org * @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); } class BitlyUrlPlugin extends UrlShortenerPlugin { public $serviceUrl; function onInitializePlugin(){ parent::onInitializePlugin(); if(!isset($this->serviceUrl)){ throw new Exception("must specify a serviceUrl"); } } protected function shorten($url) { $response = $this->http_get($url); if(!$response) return; return current(json_decode($response)->results)->hashUrl; } function onPluginVersion(&$versions) { $versions[] = array('name' => sprintf('BitlyUrl (%s)', $this->shortenerName), 'version' => STATUSNET_VERSION, 'author' => 'Craig Andrews', 'homepage' => 'http://status.net/wiki/Plugin:BitlyUrl', 'rawdescription' => sprintf(_m('Uses %1$s URL-shortener service.'), $this->shortenerName)); return true; } }