url shortening api in php??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

url shortening api in php??

Post 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??
User avatar
jazz090
Forum Contributor
Posts: 176
Joined: Sun Apr 12, 2009 3:29 pm
Location: England

Re: url shortening api in php??

Post by jazz090 »

u tried url_rewriting with apache? just rewrite the .htaccess whenever u need to with rewrite rules and shorteneded urls.
nmreddy
Forum Commoner
Posts: 25
Joined: Wed Feb 18, 2009 5:36 am

Re: url shortening api in php??

Post 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 ..
Post Reply