View Full Version : Short URL Api Using bitly,isgd,hexio,digg,trim

May 30th, 2010, 02:44 PM
Short URL is commonly used today for several reasons: avoid url garbling, take smallest space especially for long url which need to be posted at limited space format eg: twitter, also often used to manipulate user for specific purposes eg: hiding orginal url for phising and ads/affiliation links.
There are many websites that provide shortening url services, tinyurl, bit.ly, hex.io are some of them, and as addition to my simple twitter, plurk and facebook api implementation, i have created a PHP script to create short url on the fly, currently support: tinyURL, bit.ly, is.gd, tr.im and hex.io, but you can easily add other providers.
how i can use this api?
its very easy but first you should add this class in your includes short-url class.php (http://www.jooria.com/view/file/466/short-url%20class.php)
now for example after include the class you have to doing some thing like this

echo ShortUrl::create("http://www.codingforums.com/",'tinyurl')
and you can see this simple demo sample.php (http://www.jooria.com/view/file/466/sample.php)


$url = 'http://codingforums.com';
echo ShortUrl::create($url,'trim');
echo '<hr />';
echo ShortUrl::create($url,'tinyurl');
echo '<hr />';
echo ShortUrl::create($url,'isgd');
echo '<hr />';
echo ShortUrl::create($url,'hexio');
echo '<hr />';
echo ShortUrl::create($url,'bitly','your_user_name','your_api_key');