Dec 2009 24
Hello, Hello, Hello. Quick tut on bit.ly in PHP, nothing more nothing less (and yes I said PHP not Perl like I am so fond of). In order to use this code you need a bit.ly account. Visit http://bit.ly/account/register?rd=/ to get a login and a API Key.
Here is the function:
<?php function shortenURL($url) { $login = "yourlogin"; $apikey = "your api key"; $newurl = file_get_contents("http://api.bit.ly/shorten?version=2.0.1&longUrl=".$url."&login=".$login."&apiKey=".$apikey); $content = json_decode($newurl,true); $error = $content["errorCode"]; if ($error == 0){ $newurl = $content["results"][$url]["shortUrl"]; }else { $newurl = 0; } return $newurl; } ?>
Just include this file in any script and call
and boom it’s shortened.
Merry Christmas you filthy animal.






