WPBuzzer WordPress Plugin Workaround
Google Buzz just launch last February 9, 2010 and I am surprised how viral as it spread the web. A day after I noticed Mashable has a Buzz button in their post so that a reader can easily add the article to their buzz stream. So I hit google hoping that there is a plugin like this for wordpress. I see a couple of plugins available and I choose WPBuzzer because of the stat counter that can be displayed if you have bit.ly api. I download the plugin and install it in my blog, but unfortunately it doesnt work. It is because of the function file_get_contents which is disabled in my host.
So I decided to experiment the code to have it work in my host or possibly make it works for everybody wants this plugin. So heres the code I have come up.
Code below is the function that gets stats from the bit.ly service. Noticed that it uses file_get_contents function to get the data.
function wpbuzzer_get_bitlycount($shorturl,$login,$appkey)
{
// Bit.ly api call
$bitly = 'http://api.bit.ly/stats?version=2.0.1&shortUrl='.urlencode($shorturl).'&login='.$login.'&apiKey='.$appkey.'&format=json';
// Get the stats
$response = file_get_contents($bitly);
// parse json and return the URL
$json = @json_decode($response,true);
if (array_key_exists('results', $json)) {
return $json['results']['clicks'];
} else {
return false;
}
}
This is the workaround I came up. Instead of the file_get_contents I uses the CURL library to get the data.
function wpbuzzer_get_bitlycount($shorturl,$login,$appkey)
{
// Bit.ly api call
$bitly = 'http://api.bit.ly/stats?version=2.0.1&shortUrl='.urlencode($shorturl).'&login='.$login.'&apiKey='.$appkey.'&format=json';
// Get the stats
//$response = file_get_contents($bitly);
$ch = curl_init($bitly);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
$response = $output;
// parse json and return the URL
$json = @json_decode($response,true);
if (array_key_exists('results', $json)) {
return $json['results']['clicks'];
} else {
return false;
}
}
Is this the right solution? or is this one is less secure compare to the original code?
Download the original plugin from hameedullah site. And you can try the one I have edited.
I have sent an email to the original author on this plugin if he could do the fix.


16. Feb, 2010 











After installing it, I don’t see the counter of Buzz.
Just check that out on my blog at http://www.mohammedarif.com
Thanks
Mohammed Arif
Did you add your bit.ly API login and Key?
Great article. There is a lot of good information here, though I did want to let you know something – I am running Redhat with the latest beta of Firefox, and the look and feel of your blog is kind of bizarre for me. I can read the articles, but the navigation doesnt function so great.
Im sorry to know that. I try to find ways. Thanks for letting me know.