Skip to content

Instantly share code, notes, and snippets.

@rthrash rthrash/bitly.php
Created Aug 15, 2010

What would you like to do?
$link = urlencode($link);
//return getSmallLink($link);
//function getSmallLink($longurl){
$url = "$link&format=txt&history=1";
$s = curl_init();
curl_setopt($s,CURLOPT_URL, $url);
$result = curl_exec($s);
curl_close( $s );
// swap to a domain
$jmp = substr($result, 13);
return (!$urlencode) ? ''.$jmp : urlencode(''.$jmp);
// for JSON
//$obj = json_decode($result, true);
//return $obj["results"]["$longurl"]["shortUrl"];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.