package.xml 0000664 0001750 0001750 00000012474 12453736214 011316 0 ustar jan jan
Horde_Service_UrlShortener
pear.horde.org
Horde_Service_UrlShortener Class
Interfaces to various URL shortening services.
Michael J Rubinsky
mrubinsk
mrubinsk@horde.org
yes
2015-01-09
2.0.2
1.0.0
stable
stable
LGPL-2.1
* [jan] Add Composer definition.
5.3.0
6.0.0alpha1
6.0.0alpha1
1.7.0
Horde_Exception
pear.horde.org
2.0.0
3.0.0alpha1
3.0.0alpha1
Horde_Url
pear.horde.org
2.0.0
3.0.0alpha1
3.0.0alpha1
Horde_Http
pear.horde.org
2.0.0
3.0.0alpha1
3.0.0alpha1
1.0.0alpha1
1.0.0alpha1
alpha
alpha
2011-10-11
LGPL-2.1
* First alpha release.
1.0.0RC1
1.0.0RC1
beta
beta
2011-10-19
LGPL-2.1
* [jan] Fix dependency.
1.0.0
1.0.0
stable
stable
2011-11-02
LGPL-2.1
* First stable release.
2.0.0alpha1
1.0.0
alpha
stable
2012-07-05
LGPL-2.1
* First alpha release for Horde 5.
2.0.0beta1
1.0.0
beta
stable
2012-07-19
LGPL-2.1
* First beta release for Horde 5.
2.0.0
1.0.0
stable
stable
2012-10-30
LGPL-2.1
* First stable release for Horde 5.
2.0.1
1.0.0
stable
stable
2012-11-22
LGPL-2.1
* [jan] Re-packaged 2.0.0 release.
2.0.2
1.0.0
stable
stable
2015-01-09
LGPL-2.1
* [jan] Add Composer definition.
Horde_Service_UrlShortener-2.0.2/lib/Horde/Service/UrlShortener/Base.php 0000664 0001750 0001750 00000002251 12453736214 024311 0 ustar jan jan
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @category Horde
* @package Service_UrlShortener
*/
/**
* Horde_Service_UrlShortener Base class
*
* @author Michael J Rubinsky
* @category Horde
* @package Service_UrlShortener
*/
abstract class Horde_Service_UrlShortener_Base
{
/**
* @var array
*/
protected $_params;
/**
* @var Horde_Http_Client
*/
protected $_http;
/**
* Constructor
*
* @param Horde_Http_Client $http [description]
* @param array $params = array() [description]
*
* @return Horde_UrlShorten
*/
public function __construct(Horde_Http_Client $http, $params = array())
{
$this->_http = $http;
$this->_params = $params;
}
abstract public function shorten($url);
} Horde_Service_UrlShortener-2.0.2/lib/Horde/Service/UrlShortener/Exception.php 0000664 0001750 0001750 00000001025 12453736214 025373 0 ustar jan jan
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Service_UrlShortener
*/
class Horde_Service_UrlShortener_Exception extends Horde_Exception_Wrapped
{
}
Horde_Service_UrlShortener-2.0.2/lib/Horde/Service/UrlShortener/TinyUrl.php 0000664 0001750 0001750 00000002434 12453736214 025050 0 ustar jan jan
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @category Horde
* @package Service_UrlShortener
*/
/**
* UrlShortener class for TinyUrl.
*
* @author Michael J Rubinsky
* @category Horde
* @package Service_UrlShortener
*/
class Horde_Service_UrlShortener_TinyUrl extends Horde_Service_UrlShortener_Base
{
const API_URL = 'http://tinyurl.com/api-create.php';
/**
*
* @param string $url The URL to shorten
*
* @return string The shortened URL
* @throws Horde_UrlShorten_Exception
*/
public function shorten($url)
{
$u = new Horde_Url(self::API_URL);
$u = $u->setRaw(true)->add('url', $url);
try {
$response = $this->_http->get($u);
} catch (Horde_Http_Exception $e) {
throw new Horde_Service_UrlShortener_Exception($e);
}
return $response->getBody();
}
}