简体   繁体   English

Facebook评论框插件

[英]Facebook comment box plugin

I am using Facebook comment box plugin:我正在使用 Facebook 评论框插件:

<fb:comments href="${myPageUrl}" num_posts="20" width="630"></fb:comments>

Every thing is working fine.一切正常。 The problem is that I want to store the comment posted into my database.问题是我想将发布的评论存储到我的数据库中。 Is there any way to fetch the text posted on the comment box.有什么方法可以获取评论框中发布的文本。

I am using the following js to catch comment-create event.我正在使用以下 js 来捕获comment-create事件。

FB.Event.subscribe('comment.create', function(response) {        
        alert(response.commentID)
});

I'm getting some commentId from this but I don't know how to fetch the exact comment posted on a particular comment-create event.commentId得到了一些commentId ,但我不知道如何获取发布在特定comment-create事件上的确切评论。

Coomie: Actually whenever a comment is posted, I catch the event thru 'comment.create'. Coomie:实际上,每当发表评论时,我都会通过“comment.create”来捕捉事件。 I was able to catch the event but I was wondering how to get the comment(text) posted at that particular event.我能够赶上该事件,但我想知道如何在该特定事件中发布评论(文本)。 Like event.text or event.comment but there was no direct method found像 event.text 或 event.comment 但没有找到直接的方法

So, now I am manipulating it with fql.所以,现在我用 fql 来操作它。 Which is somewhat similar to you example.这与您的示例有些相似。 First retrieving the whole list and then selecting the top one.首先检索整个列表,然后选择顶部的。 My sample code is below:我的示例代码如下:

FB.Event.subscribe('comment.create', function(response) {
      FB.api({
        method: 'fql.query',
        query: "SELECT post_fbid, fromid, object_id, text, time from comment WHERE  object_id in (select comments_fbid from link_stat where url ='${PageUrl}') order by time desc limit 1"
      },
      function(response) {
        var feed = response[0];          
        alert(feed.text)
      });
});  

So this method is giving me exactly the same result I want.所以这种方法给了我完全相同的结果。

FB.Event.subscribe('comment.create', function(response) { var commentQuery = FB.Data.query('SELECT fromid, text FROM comment WHERE post_fbid=\'' + response.commentID + '\' AND object_id IN (SELECT comments_fbid FROM link_stat WHERE url=\'' + response.href + '\')'); FB.Data.waitOn([commentQuery], function () { text = commentQuery.value[0].text; // Use your preferred way to inform the server to save comment $.post( 'http://example.com/comment', text ) }); });

I don't have the complete answer but this should get you on your way.我没有完整的答案,但这应该会让你上路。

You can use the facebook graph api to extract information about an open graph id (an open graph id is FB's way of identifying a person, website, application or URL).您可以使用 facebook 图形 API 来提取有关开放图形 id 的信息(开放图形 id 是 FB 识别个人、网站、应用程序或 URL 的方式)。 Eg.例如。 this page: http://www.inhousegroup.com.au/newsroom/23-best-practice-for-advanced-seo/ (the place that fired me) uses a comment box.此页面: http : //www.inhousegroup.com.au/newsroom/23-best-practice-for-advanced-seo/ (解雇我的地方)使用评论框。 The web page has an open id of 10150441190653416. So when you comment on this page facebook sees your comment as a wall post on that page's "wall".该网页的打开 ID 为 10150441190653416。因此,当您在此页面上发表评论时,facebook 会将您的评论视为该页面“墙”上的墙贴。

Using the graph api, you can get some JSON info about the page here: http:/graph.facebook.com/10150441190653416使用图形 API,您可以在此处获取有关该页面的一些 JSON 信息:http://graph.facebook.com/10150441190653416

And you can get the posts from this address: http://graph.facebook.com/10150441190653416/posts你可以从这个地址获取帖子: http : //graph.facebook.com/10150441190653416/posts

But you'll have to get an access token.但是您必须获得访问令牌。

Then you just have to import the posts on save and compare your db to the JSON and add records as neccessary.然后,您只需在保存时导入帖子并将您的数据库与 JSON 进行比较,并根据需要添加记录。

Good luck!祝你好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM