Skip to content

Instantly share code, notes, and snippets.

@frozonfreak
Created January 13, 2015 08:19
Show Gist options
  • Save frozonfreak/2d308af66bcdf0646540 to your computer and use it in GitHub Desktop.
Save frozonfreak/2d308af66bcdf0646540 to your computer and use it in GitHub Desktop.
Get short url from bitly and viceversa
/* returns the shortened url */
function get_bitly_short_url($url,$login,$appkey,$format='txt') {
$connectURL = 'http://api.bit.ly/v3/shorten?login='.$login.'&apiKey='.$appkey.'&uri='.urlencode($url).'&format='.$format;
return curl_get_result($connectURL);
}
/* returns expanded url */
function get_bitly_long_url($url,$login,$appkey,$format='txt') {
$connectURL = 'http://api.bit.ly/v3/expand?login='.$login.'&apiKey='.$appkey.'&shortUrl='.urlencode($url).'&format='.$format;
return curl_get_result($connectURL);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment