. * * @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 PtitUrlPlugin 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(sprintf($this->serviceUrl,urlencode($url))); if (!$response) return; $dom = new DOMDocument(); @$dom->loadHTML($response); $y = @simplexml_import_dom($dom); if (!isset($y->body)) return; $xml = $y->body->center->table->tr->td->pre->a->attributes(); if (isset($xml['href'])) { return strval($xml['href']); } } }