English 中文(简体)
如何用图表 Api ajax 调用 # facebook 评论 # facebook Comment
原标题:How to get # facebook comments using graph api ajax call
var url =  https://graph.facebook.com/?ids=http://www.stackoverflow.com ;

$.getJSON(url, function(resp) {
  $("p").html( comments =   + resp.comments);
});

这将在我的 中设置以下 html : comments = 未定义的

我从电话中得到的返回字符串是:

{
   "http://www.thinlinebetween.com/tuesday-quote-of-the-day-jean-ingelow/": {
      "id": "http://www.thinlinebetween.com/tuesday-quote-of-the-day-jean-ingelow/",
      "shares": 2,
      "comments": 1
   }
}

http://www.thinline between.com/tuesday-quote-of-day-jean-ingelow/.comments 来获得价值?返回的json不容易解析。谢谢!

问题回答
var postUrl =  http://www.stackoverflow.com ;
var apiUrl =  https://graph.facebook.com/?ids=  + postUrl;

$.getJSON(apiUrl, function(resp) {
  $("p").html( comments =   + resp[postUrl].comments);
});

需要做 resp["http://www.stackoverflow.com"].com/comments

这应该是办法,

$(function(){ 
        var webUrl =  http://www.stackoverflow.com ;
        var endpoint =  https://graph.facebook.com ;
        $.getJSON(endpoint,{ ids :webUrl},function(response){
            var comments = response[webUrl].comments;
              $("p").html( comments =   + comments);
        })
    });




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签