Created
January 13, 2015 08:19
-
-
Save frozonfreak/2d308af66bcdf0646540 to your computer and use it in GitHub Desktop.
Get short url from bitly and viceversa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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