我希望关注者可以从twitter站点进行计数,我已经使用了此查询,它的效果很好,但是现在不起作用,因为twitter API现已更改。我使用了脚本来获取跨度id ="spnTwitterFolowersCount"的计数。

<script>
    $.getJSON("https://twitter.com/users/Obama.json?callback=?",

    function (data) {
        document.getElementById("spnTwitterFolowersCount").innerHTML = data.followers_count;
        //alert('Obama has ' + data.followers_count + ' Followers');
    });
</script>

最佳答案

由于可以从Twitter个人资料上的任何人访问关注者计数,因此您可以使用YQL:

var ttid = "twitterUsername";
var response = $.getJSON("https://query.yahooapis.com/v1/public/yql?q=select%20content%20from%20html%20where%20url%3D%22https%3A%2F%2Ftwitter.com%2F"+ttid+"%22%20and%20xpath%3D'%2F%2Fli%5Bcontains(%40class%2C%22ProfileNav-item--followers%22)%5D%2Fa%2Fspan%5Bcontains(%40class%2C%22ProfileNav-value%22)%5D'&format=json&callback=");
return response.success(function (followers) {
    return followers;
});

10-07 15:18