Page 1 of 1

url shortening api in php??

Posted: Mon Apr 20, 2009 1:47 am
by susrisha
hi,
I have a script that dynamically generates files and links for those files.
I have seen http://tinyurl.com which shortens the url when given a long url into a smaller one.

My problem is i want to generate the short urls dynamically so that everytime i create the urls, i get the short urls dynamically.
is there an api for doing the same??

Re: url shortening api in php??

Posted: Mon Apr 20, 2009 4:44 am
by jazz090
u tried url_rewriting with apache? just rewrite the .htaccess whenever u need to with rewrite rules and shorteneded urls.

Re: url shortening api in php??

Posted: Mon Apr 20, 2009 4:44 am
by nmreddy
The below code ,i found on google search

function shortenurl($url){
if(strlen($url) > 45){
return substr($url, 0, 30)."[...]".substr($url, -15);
}else{
return $url;
}
}

may be useful ,if not leave it ..