Facebook Api getting feeds and comments

2020-07-18 08:49发布

I'm trying to get the feeds on a public wall and the associated comments. So every X minutes I'm doing a query in order to get what's new (feeds and comments).

I need the feeds (the new feeds since myDate) and comments (comments posted on the new feeds and comments posted on older feeds). So if someone posted a comment on a older feed I want to get it. I tryied to do this using FQL and Graph API but I don't manage to find the best solution.

With FQL there are some problems (bugs) with LIMIT and OFFSET and does not work very well. With the Graph API I don't have so much power. So this is what I've tryied:

https://graph.facebook.com/PAGE_ID/feed?access_token=MY_ACCES_TOKEN0&limit=500&since=1350033469&until=now&updated_time>1350033469

This gives me the newest post, so no problem because for each one I'm doing a new query in order to get the comments for each feed:

https://graph.facebook.com/PAGE_ID/comment?access_token=MY_ACCES_TOKEN0&limit=500&since=1350033469&until=now&updated_time>1350033469

The problem is that if a comment is posted on a older post, I don't receive it.

Using FQL I cannot filter only the newest posts (based on my since date) and the posts with new comments.

https://api.facebook.com/method/fql.query?query=SELECT post_id, text, fromid FROM comment WHERE post_id IN (SELECT post_id FROM stream where source_id=PAGE_ID and comments.created_date>1350033469)&access_token=MY_ACCES_TOKEN

Using Graph API I have a good pagination (using next and previous links inside the response) but with FQL I did't find any solution.

So anyone have some idea ? Thanks.

C.C.

1条回答
该账号已被封号
2楼-- · 2020-07-18 09:33

First, the FQL is deprecating, so you need to use only the Graph API.

The solution that I came with, is that when you already have a post, you need to recheck the post with its unique ID, and that request gives you two times, created_time and updated_time, so you need to check if your updated_time changed.

The pagination given in the Graph API is for only posts, so when posts have new comments, they won't come first in the list, you need to find them yourself.

-- UPDATE --

Use batch_requests to achieve this, so you can make more requests at a time.

查看更多
登录 后发表回答