Facebook comment FQL and comment box - facebook

I'm syncing Facebook comments to a database and showing the Facebook comment box on a webpage. There are some inconsistencies with what is synced and what is shown in the Facebook comments box.
First I'm getting the comments with an FQL query. The FQL is as follows:
SELECT post_fbid, fromid, object_id, text, time FROM comment WHERE object_id in
(SELECT comments_fbid FROM link_stat WHERE url = 'http://www.storaensometsa.fi/metsa-ja-mina/')
If you run the query in Facebook Graph API Explorer it returns two comments.
Now, if I add a Facebook comment box to the page above (http://www.storaensometsa.fi/metsa-ja-mina/) it shows zero comments (scroll down the page to see the comment box).
Any thoughts why this is happening? Shouldn't there be two comments in the comment box also? Is the FQL query somehow incorrect?

Why really is FQL necessary? You have to write such a complex query to get the comments, where you can easily get them using the Graph API /comments. Here's the API call:
/comments?id={url}
So to get the comments from your url, simply \GET:
http://graph.facebook.com/comments?id=http://www.storaensometsa.fi/metsa-ja-mina/
(you can check the result in the browser)

Related

How to limit Facebook Graph API to only posts (not comments or likes) by user without using FQL?

I am trying to query the FB graph API for all of my posts. I would like the result set to only feature items that I've posted on my timeline. Not other users, and not my likes or comments.
The documentation is extremely confusing and most of the knowledge I've gained is through trial and error. To date, the only proposed solutions to this I've found online require the use of FQL (such as in this similar question: Facebook graph api- how to get user feed,with out posts about likes and comment by the user?) however the FB documentation states that FQL is deprecated and will not be supported in the future so I would like to avoid it. Additionally this is currently structured as a url request and if at all possible, I would like to keep it so.
To date, I've tried:
/[userid]?fields=posts.limit(100).fields( picture, link, created_time, from, message, description, object_id )
which will get me all of my posts with the data fields I require, but it also includes "Likes" and when I "Comment" anywhere - which I don't want.
/[userid]?fields=feed.limit(100).fields( picture, link, created_time, from, message, description, object_id )
which returns only posts - but also includes posts made by others on my timeline (and I don't want those either).
It seems unclear to me if there is any more robust way to work with these different feed types as documented:
https://developers.facebook.com/docs/graph-api/reference/v2.0/user/feed/
Can anyone tell if there is a way to either limit the "feed" edge to only my posts (not including others posting to my timeline) or filter the "posts" edge to remove the "likes" and "comments"?
Instaead of /feed, you can use /posts.
More info here:
https://developers.facebook.com/docs/graph-api/reference/v2.0/user/feed
It's not possible as far as I know to generally apply filters to the Graph API calls, except very little exceptions.
/user/feed is an example (https://developers.facebook.com/docs/graph-api/reference/v2.0/user/feed/#read), where you can specify either with=location or filter={stream_filter}.
{stream_filter} in this case is a result of the filter_key field of the following FQL query:
select filter_key, name from stream_filter where uid=me()
Maybe you can try
GET /me/feed?filter=app_2915120374
which should give you the status updates.

Retrieve ALL Facebook Comments for website/App ID Using Graph API (i.e. get latest comments)

I'm trying to create a feed of latest comments for a website. I don't have any problem getting comments on a per post basis but I don't seem to be able to find any way to get all, or at least the last 10 comments for the entire website.
Obviously I'd like to do this in the simplest way possible and I figured this would be via the Graph API.
Any suggestions appreciated.
Thanks
I think you might have to enter all the URLs, but it can be done via FQL using the comments and link_stat table.
SELECT xid, text, username, time
FROM comment
WHERE
object_id IN
(SELECT comments_fbid FROM link_stat WHERE url IN (All_your_URLs))
Can you try the above and see if it works ?
Reference - Comments & Link_Stat

Post new comment to facebook comments using fql

I have successfully retrieved the comments on a specific link using the fql with the following code:
{\"comments\":\"SELECT fromid, text, time, comments FROM comment WHERE object_id IN (SELECT comments_fbid FROM link_stat WHERE url ='http://permalink')\", \"users\":\"SELECT name, id FROM profile WHERE id IN (SELECT fromid FROM #comments)\"}
I want to post new comment and I have the access token of the user, what is the right way to do this using fql?
As far as I'm aware,you can't insert using FQL. FQL is merely a query language used to perform more complex queries than the Graph API endpoints offer allowing you to perform joins etc (Not joins in the traditional sense but using "IN" statements).
You would need to use the graph api and issue a POST request as detailed towards the bottom of this page https://developers.facebook.com/docs/reference/api/link/

Facebook FQL query to return all comments against an application [duplicate]

We use the facebook comment plugin to have comments on our site.
To moderate those, we use this tool: https://developers.facebook.com/tools/comments
However, we want to build our own tool to moderate those comments, and integrate it to our existing software.
I can't find a proper way of doing this. the only way I found out now after hours of research is this FQL query:
select post_fbid, fromid, object_id, text, time from comment where object_id in (select comments_fbid from link_stat where url ='URL_HERE')
That doesn't work because we have thousands of different URL's and I cant query each of them every time to see if there are any new comments.
I need a way to get all (new) comments by just enter our app_id, domain or something like that
How can I do this?
I'm considering doing the same thing- grabbing all user posts for my application. I'm assuming it's a similar task.
For given user, I will scroll through feed and home looking for app posts. For you, you'd go:
`home?fields=comments`
`feed?fields=comments`
And check for "type" and "id" to match your application.
This code queries for all comments xids used by your application:
https://graph.facebook.com/fql?q=SELECT fromid, text, id, time, username, xid, object_id FROM comment WHERE xid IN (SELECT xid FROM comments_info WHERE app_id = {0}) ORDER BY time desc&access_token={1}&format=json

Trouble with FQL stream_tag

I am trying to retrive posts from a users news feed in which my fan page has been tagged. I'm seaching through stream_tag with FQL but zero results are returned.
Posted a comment on my wall in which I tagged a friend, myself, and my fan page.
Used the Graph API Explorer - developers.facebook.com/tools/explorer/
Used the explorer as one of my apps, and granted every type of permission.
Did the following query:
https://graph.facebook.com/fql?q=SELECT post_id,actor_id FROM stream_tag WHERE target_id = [fan page id]
The following is returned: data: []
This seems to indicate that there is no resaults but I know the tag exists. When I do a query with target_id=me() results are returned, but according to the documentation the target_id can also be a fan page( http://developers.facebook.com/docs/reference/fql/stream_tag/ to craft the query).
How can I create a query that returns posts my fan page is tagged in?
I was trying to do the exact same thing when I came across your post. It looks like there currently is a bug report open that the stream_tag table does not work with when the target is a page.