This code will do the trick for bit.ly short URLs:
function bitly($longUrl) {
$bitly = json_decode(file_get_contents('https://api.bit.ly/shorten?version=2.0.1&login=YOUR_LOGIN&apiKey=YOUR_API_KEY&longUrl=' . $longUrl), true);
return $bitly['results'][$longUrl]['shortUrl'];
}
add_filter('tweet_blog_post_url', 'bitly');
Like the others guys have said, find the functions.php for your WordPress theme (i.e. wp-content/themes/default/functions.php) and place it there.
Note that you’ll need to sign up for a bit.ly account if you don’t already have one, and replace YOUR_LOGIN and YOUR_API_KEY with your own.
If this doesn’t work, chances are your PHP installation doesn’t allow file_get_contents() to access URLs.