Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tweet Button - hiding zero count

I'm interested in adding to some of my sites the official Tweet button which Twitter have recently released.

For those unaware, the tweet button is a simple bit of JS which you can drop in to a page and it allows your users to easily tweet about the page in question, much like the facebok "share" button.

There are 3 different styles available:

Tweet button styles

The horizontal count button is the one I'd like to put on my pages. My problem is that roughly half of my pages are likely to have a zero count, and I'd rather not show the count when this is the case. The facebook share button, for example, handles this particular situation well - if there are > 0 shares, then it shows the count. Otherwise the count stays hidden.

I've gone through the twitter docs, and can't seem to find a way of specifying this in the JS parameters.

I also spent some time trying to capture the count via jquery and hide it, but quickly ran in to cross-domain permission issues -

console.log($('.twitter-share-button').contents().html());

returns a Permission denied error due to the iframe being loaded from platform0.twitter.com.

Has anyone yet found a successful way to get this button to conditionally show the tweet counts as described above?

like image 389
ConroyP Avatar asked Sep 02 '10 12:09

ConroyP


1 Answers

A google search later, found http://ottopress.com/2010/twitters-new-tweet-button-and-the-count-api/ which talks about how to use the count api http://urls.api.twitter.com/1/urls/count.json?url=URL-TO-GET-COUNT-FOR.

like image 130
vsr Avatar answered Dec 14 '22 09:12

vsr