Javascript JSON-从url获取facebook总计数

Javascript JSON-从url获取facebook总计数,javascript,json,facebook,facebook-graph-api,facebook-fql,Javascript,Json,Facebook,Facebook Graph Api,Facebook Fql,此脚本获取facebook粉丝页面上的赞数 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript"> $(function() { //Set Url of JSON data from the facebook graph api.

此脚本获取facebook粉丝页面上的赞数

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
//Set Url of JSON data from the facebook graph api. make sure callback is set   with a '?' to overcome the cross domain problems with JSON
var url = "https://graph.facebook.com/tenniswarehouse?callback=?";

//Use jQuery getJSON method to fetch the data from the url and then create our unordered list with the relevant data.
$.getJSON(url,function(json){
    var html = "<ul><li>" + json.likes + "</li></ul>";
    //A little animation once fetched
    $('.facebookfeed').animate({opacity:0}, 500, function(){
        $('.facebookfeed').html(html);
    });
    $('.facebookfeed').animate({opacity:1}, 500);
});
});
</script>
</head>
<body>
<div class="facebookfeed">
<h2>Loading...</h2>
</div>
</body>
</html> 

$(函数(){
//设置facebook graph api中JSON数据的Url。确保回调设置为“?”,以克服JSON的跨域问题
变量url=”https://graph.facebook.com/tenniswarehouse?callback=?";
//使用jQuery getJSON方法从url获取数据,然后使用相关数据创建无序列表。
$.getJSON(url,函数(json){
var html=“
  • ”+json.likes+”
”; //一个小动画一旦被抓取 $('.facebookfeed')。设置动画({opacity:0},500,function(){ $('.facebookfeed').html(html); }); $('.facebookfeed')。设置动画({opacity:1},500); }); }); 加载。。。

我试图让他从一个url(“”)中获取喜欢、分享和评论的总数,但没有成功

<script type="text/javascript">
$(function() {
//Set Url of JSON data from the facebook graph api. make sure callback is set with a '?' to overcome the cross domain problems with JSON
var url = "https://graph.facebook.com/fql?q=SELECT%20url,%20normalized_url,%20share_count,%20like_count,%20comment_count,%20total_count,commentsbox_count,%20comments_fbid,%20click_count%20FROM%20link_stat%20WHERE%20url=    %27http://www.google.com%27?callback=?";

//Use jQuery getJSON method to fetch the data from the url and then create our unordered list with the relevant data.
$.getJSON(url,function(json){
var html = "<ul><li>" + json.total_count + "</li></ul>";
//A little animation once fetched
$('.facebookfeed').animate({opacity:0}, 500, function(){
$('.facebookfeed').html(html);
});
$('.facebookfeed').animate({opacity:1}, 500);
});
});
</script>
</head>
<body>
<div class="facebookfeed">
<h2>Loading...</h2>
</div>
</body>
</html>

$(函数(){
//设置facebook graph api中JSON数据的Url。确保回调设置为“?”,以克服JSON的跨域问题
变量url=”https://graph.facebook.com/fql?q=SELECT%20url,%20normalized\u url,%20share\u count,%20like\u count,%20comment\u count,%20total\u count,commentsbox\u count,%20comments\u fbid,%20click\u count%20来自%20link\u stat%20其中%20url=%27http://www.google.com%27?callback=?";
//使用jQuery getJSON方法从url获取数据,然后使用相关数据创建无序列表。
$.getJSON(url,函数(json){
var html=“
  • ”+json.total_count+”
”; //一个小动画一旦被抓取 $('.facebookfeed')。设置动画({opacity:0},500,function(){ $('.facebookfeed').html(html); }); $('.facebookfeed')。设置动画({opacity:1},500); }); }); 加载。。。
你能帮我让脚本从链接中获取“”吗?

我想

var html = "<ul><li>" + json.data[0].total_count + "</li></ul>";
var html=“
  • ”+json.data[0]。总计数+”
”;
应该做。。。还要确保从FQL中的URL中删除多余的空格


看看这把小提琴:

它不起作用。我不能删除一些空格,因为之后它就不起作用了。我不明白你的意思。您的FQL:
中有多余的空间,其中%20url=%27http://www.google.com
这是我删除多余空格的url,但它不起作用。什么例子不起作用?你应该更具体些,否则没人能帮你。。。