Here's how you can create short URLs using Bit.ly services
/* 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 a result form url */ 
function curl_get_result($url) 
{ 
    $ch = curl_init(); 
    $timeout = 5; 
    curl_setopt($ch,CURLOPT_URL,$url); 
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); 
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout); 
    $data = curl_exec($ch); 
    curl_close($ch); 
    return $data; 
} 
/* get the short url */ 
$tweet = get_bitly_short_url('URL','login_id','app_key');
$tweet = urlencode($tweet);
                       
                    
0 Comment(s)