gpt4 book ai didi

javascript - 使用 facebook fql 查询将所有帖子评论限制在限制范围内

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:36:02 24 4
gpt4 key购买 nike

我一直在尝试使用 Fql 查询来显示帖子的所有评论。首先我显示 2 个帖子,然后当单击“显示更多评论”时我显示接下来的 50 条评论,这样它继续。当“显示更多评论”时我通过 ajax 调用 graph api 执行以下 -

SELECT text,post_id  FROM comment  WHERE post_id=post_id limit 50

但是说,当我第一次点击“显示更多评论”时,它显示了 52 条评论,然后当我再次点击时,它显示了大约 102 条评论。但是对于下一次点击,152 条评论没有显示。它停留在大约 102 条评论。

我的目标 -

第一次点击“显示更多评论”= 从第一条评论开始显示 52 条评论(限制值 = 52 我在查询中指定)

第二次点击 = 显示从第一条评论开始的 102 条评论(限制值=102)

第三次点击 = 从第一条评论开始显示 152 条评论(限制值=152)......继续

所以我无法实现这一点。我真的尝试了很多使用偏移的方法。很多问题。Facebook 有错误吗?请尽快提供帮助。

最佳答案

您应该尝试游标分页,建议按照 https://developers.facebook.com/docs/reference/api/pagination/ 中的说明进行操作

Returned results under cursor paging more consistently match the limit requested, even after hiding any records for which you do not have permissions to view (eg. if you request 10 records, but do not have permissions to see 3 of those records, 3 additional records will be pulled transparently, so that a full 10 records are pulled).

post_id_cursor 示例:

SELECT text, post_id, post_id_cursor FROM comment WHERE post_id='22707976849_10151395520781850' ORDER BY time DESC limit 50

您获得最后一条评论的 post_id_cursor,然后使用 >post_id_cursor 符号导航下一页

SELECT text, post_id, post_id_cursor FROM comment WHERE post_id='22707976849_10151395520781850' AND  post_id_cursor>'Mjg3NA==' ORDER BY time DESC limit 50

object_id_cursor 的例子是一样的:

SELECT text, post_id, object_id_cursor FROM comment WHERE object_id='10151395520696850' ORDER BY time DESC limit 50

SELECT text, post_id, time, object_id_cursor FROM comment WHERE object_id='10151395520696850' AND object_id_cursor>'Mjg3NA==' ORDER BY time DESC limit 50

Update:

Make sure you enabled "July 2013 Breaking Changes:" field at your app advanced settings, https://developers.facebook.com/apps/YOUR_APP_ID/advanced. More info at https://developers.facebook.com/roadmap

Example of get feed for certain user:

https://developers.facebook.com/tools/explorer?fql=%7B%22query1%22%3A%22SELECT%20post_id%2C%20actor_id%2C%20created_time%2C%20message%20FROM%20stream%20WHERE%20source_id%3D611693239%20AND%20created_time%3C%3Dnow()%20LIMIT%2050%20%22%2C%22query2%22%3A%22SELECT%20post_id%2C%20id%2C%20fromid%2C%20time%2C%20text%2C%20user_likes%2C%20likes%20FROM%20comment%20WHERE%20post_id%20IN%20(SELECT%20post_id%20FROM%20%23query1)%20LIMIT%205%20%22%2C%22query3%22%3A%22SELECT%20id%2C%20name%2C%20pic_square%20FROM%20profile%20WHERE%20id%20IN%20(SELECT%20actor_id%20FROM%20%23query1)%20or%20id%20IN%20(SELECT%20fromid%20FROM%20%23query2)%22%7D%0A

关于javascript - 使用 facebook fql 查询将所有帖子评论限制在限制范围内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16327285/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com