As diafol pointed, you are not doing the login in your curl request. Anyway I use this function, that make use of file_get_contents() and works pretty well:
<?php
function getlink($url)
{
$version = '2.0.1';
$format = 'xml';
$login = 'username';
$appkey = 'API_KEY';
$bitly = 'http://api.bit.ly/shorten?version='.$version.'&longUrl='.urlencode($url).'&login='.$login.'&apiKey='.$appkey.'&format='.$format;
$response = file_get_contents($bitly, TRUE);
if($response !== FALSE)
{
$xml = simplexml_load_string($response);
$link = 'http://bit.ly/'.$xml->results->nodeKeyVal->hash;
return $link;
} else {
return FALSE;
}
}
echo getlink('http://www.website.tld');
?>
which is based on http://davidwalsh.name/bitly-php
bye!