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:
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 situa开发者_如何学Gotion 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?
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
.
Not the most elegant solution, but you could always stagger the release of the different button types.
Eg, show the 'no count' button initially, then display the 'horiztonal count' say, a week from the publication date. (i'm making the assumption you're running some type of blog)
Again, not great, but it partially solves your problem - you'll display the 'zero tweets' button less often.
Regards Luke
精彩评论