shorten links

Shorten links with bit.ly using jQuery

function get_short_link($url) 
{
  $bitly_login="yourloginname";
  $bitly_apikey="yourapikey";
  $api_call = file_get_contents("http:api.bit.lyshorten?version=2.0.1&longUrl=".$url."&login=".$bitly_login."&apiKey=".$bitly_apikey);
  $bitlyinfo=json_decode(utf8_encode($api_call),true);
  if ($bitlyinfo['errorCode']==0) 
  {
      return $bitlyinfo['results'][urldecode($url)]['shortUrl'];
  } 
  else 
  {
      return false;
  }
}