I have looked through the API's of facebook and twitter but i cannot seem to find the answer to my question.

On websites like http://punchfork.com/recipe/Porkitos-Crispy-Prosciutto-Chips-Nom-Nom-Paleo

On the right hand side they have the social stats page with information such as Tweets, Facebook Shares and Stumbleupons.

My question is how do they record or gather these results? Is it a case of they have a button that records it in their database then sends you to the page to tweet/share/stumble? But surely that couldn't be accurate as people might not continue to fill out the action.

有帮助吗?

解决方案

Since people seem to dislike the 3rd party solution, here's another using jQuery:

    // Get Number of Twitter Followers From Twitter.com
    $.getJSON('http://twitter.com/users/USERHANDLE.json?callback=?',function(data) {
        if ('followers_count' in data) {
            $('.followercount').text(format_number(data.followers_count,0,'',','));
        }
    });

    // Get facebook likes
    $.getJSON("https://graph.facebook.com/ACCOUNTNAME?callback=?", function(data) { 
        if ('likes' in data) {
            $('.likecount').text(format_number(data.likes,0,'',','));

        }
    });

And if you're looking for # of tweets for a certain term, the url is:

http://search.twitter.com/search.json?q=SEARCHTERM&rpp=10&lang=en&callback=?

And if you want "shares" for a url on facebook it is:

http://graph.facebook.com/http://www.google.com

If the url you wanted was Google.

其他提示

Maybe it's a script on their website that catches the clicks and send them to a server side script that updates a database to then display it.

If your're running your site in Wordpress, there is this plugin: Top Social Stories which helps you tracking those social data by storing every day the number of shares, tweets and +1s user made on your posts.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top