<?php

function make_bitly_url ($url, $login = ‘dandande’, $api_key = ‘R_270ede619dd3f530eb9c98641e6ee***’)
{
return file_get_contents( ‘http://api.bit.ly/v3/shorten?login=’.$login .’&apiKey=’.$api_key .’&uri=’.urlencode($url) .’&format=txt’);
}
$bitly_url=make_bitly_url(‘http://www.danbaise.com’);
echo $bitly_url;


取得$api_key得到https://bitly.com/注册用户名,format提供几种格式,txt,json,xml
更多详情:http://code.google.com/p/bitly-api/wiki/ApiDocumentation