短縮URLのサービス

短縮URLのサービスをPHPから使おうかと思う。

http://to.ly/
http://to.ly/api_info.php


function getShortUrl($url) {
$surl = "";

$req = new HTTP_Request();
$req->setURL("http://to.ly/api.php?longurl=".urlencode($url));
$req->addHeader('Cache-Control', 'no-cache');
$req->setMethod(HTTP_REQUEST_METHOD_GET);

$res = $req->sendRequest();
if (PEAR::isError($res)) {
//...;

} else {
$surl = $req->getResponseBody();
}

return $surl;
}