I posted a fix on that webexpedition post linked above, but it seems that Nikola aka Colaja from Nis, Serbia removed it. Very well, I will post it here.
The issue I faced when using Coloja’s hack was that it generated a shortened url (bit.ly in my case) during the page loop. So, on the main page, where we are showing the latest 10 posts… the loop hit the bit.ly API, get a shortened URL 10 times, adding about 11 seconds to the load time of homepage–not very efficient. What I opted for was to pass permalink to a custom bit2twitt.php file that would bit.ly-ize the link only after the user clicked on it, then redirect to twitter, passing the shorted url.
To sum up what you need to do:
1. Open sociable.php and find the following block:
'Twitter' => Array(
'favicon' => 'twitter.png',
'awesm_channel' => 'twitter',
'url' => 'https://twitter.com/home?status=PERMALINK',
),
and change it to:
'Twitter' => Array(
'favicon' => 'twitter.png',
'awesm_channel' => 'twitter',
'url' => 'bit2twit.php?url=PERMALINK',
),
2. create a new file called bit2twit.php with the following code:
<?php
$url = $_GET['url'];
// Ondemand function to generate dynamic bit.ly urls
function getBitlyUrl($url) {
// fill up this 2 lines below with your login and api key
$bitlylogin = '<your bit.ly login goes here>';
$bitlyapikey= '<your bit.ly api key goes here>';
// you dont need to change below this line
$bitlyurl = file_get_contents('https://api.bit.ly/shorten?version=2.0.1&longUrl='.$url.'&login='.$bitlylogin.'&apiKey='.$bitlyapikey);
$bitlycontent = json_decode($bitlyurl,true);
$bitlyerror = $bitlycontent["errorCode"];
if ($bitlyerror == 0){
$bitlyurl = $bitlycontent["results"][$url]["shortUrl"];
}
else $bitlyurl = $url;
return $bitlyurl;
}
header('Location: https://twitter.com/home?status='.getBitlyUrl($url));
?>
3. place the bit2twit.php file you just created in your wordpress root and you are golden.