Recently I’ve been playing around with Twitter’s API, when I make a post a tweet will automatically be made on my Twitter account. I’ll get on that later. I like bit.ly, it provides short URLs in no time but its API isn’t the easiest to work with. So tinyurl.com has a long but easy to use API, I had no other choice to shorten my URLs with TinyURL, anyway something is better than nothing. Its actually pretty simple to shorten URLs with TinyURL.
Lets say we are creating a function, getTinyURL(). You can edit it to match your needs later.
function getTinyURL($url) {
$tinyurl = file_get_contents("http://tinyurl.com/api-create.php?url=".$url);
return $tinyurl;
}
So you see, you just need to provide a URL, for a example: will return http://tinyurl.com/ylxlw6kr. The TinyURL provided is longer than my sites URL
Anyway, it’ll work great for my posts which uses extremely long URLs.
2 comments
By Steve
73 days ago
I’m wondering if there is a limit per/hour, per/day, etc.. of how many tiny urls you can generate with this? But how do they even track usage without requiring you to use your own assigned id – It’s hard to believe they don’t.
Maybe they track it by I.P. address, if they do it all.
By manmohanjit
72 days ago
I don’t think there is