facebook graph api 评论列表排序,如'orderby=desc'? [英] facebook graph api comment list sort , like 'orderby=desc'?

查看:26
本文介绍了facebook graph api 评论列表排序,如'orderby=desc'?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用graph api获取图片的评论,但我想先通过创建时间对结果进行排序,然后返回最新数据.类似sql语句'order by create_time desc',不知道有没有这样的参数.

目前用于抵消和限制对最新数据的访问,但也知道评论总数,

pagesize = 25;offset = comments.count - 页面大小;限制 = 25;

<块引用>

url = "https://graph.facebook.com/" + object_id + "/comments?access_token=" + access_token + "&limit=" + limit + "&offset=" + limit;

下一页:

偏移量 -= 25

但是comments.ount的数字有时不准确

和返回的请求URL的结果有时不匹配

<块引用>

是否有很好的解决方案

或者我用错了方式(‘limit’和‘offset’参数)!!!

<小时>

感谢您的回答.

Graphics API"是否存在缓存?

我发了一条消息和46条评论.requests url,设置参数:

<块引用>

偏移=0&限制=1

然后应该返回最后一条评论(最新一条),实际返回到中间一条评论,我测试了几次,设置抵消和限制.根据返回的结果,中间的是最新评论

如果我设置的限制值大于'comment.count',返回的数据是全部,官网和facebook一致

因为缓存的原因?

再次感谢~

解决方案

@dbau - 最好还是使用 FQL.根据我的经验,除非您进行非常简单的调用,否则您几乎无法控制通过 Graph API 调用获得的内容.

你为什么不想使用 FQL?FQL 是 Graph API 的一个端点.还有一些数据只能通过FQL返回.

这将为您提供您正在寻找的结果.查询需要进行 URL 编码.为清楚起见,我将其保留为纯文本.

 https://graph.facebook.com/fql?access_token=[TOKEN]&q=SELECT id, fromid, text, time, likes, user_likes FROM 评论WHERE object_id = [OBJECT_ID] ORDER BY 时间 DESC LIMIT 0,[N]

您可能会发现每次都没有返回 [N] 条评论,因为 Facebook 过滤掉了 access_token 所有者不可见的项目之后 查询运行.您可以提高 LIMIT 并过滤掉返回的任何多余结果,或者如果您使用的是用户 access_token,则可以将 AND can_like = TRUE 添加到 WHERE 子句来保证,如果它们存在,[N] 个对当前用户可见的帖子被返回.

I use graph api to get the picture's comments, but I want to first sort the results by creating time and then return to the latest data. Similar to the sql statement 'order by create_time desc', I do not know if have such a parameter.

Currently used to offset and limit access to the latest data, but also know the total number of comments,

pagesize = 25;
offset = comments.count - pagesize;
limit = 25;

url = "https://graph.facebook.com/" + object_id + "/comments?access_token=" + access_token + "&limit=" + limit + "&offset=" + limit;

next page:

offset -= 25

but comments.ount of numerical sometimes is not accurate

and the result of the request URL to return to sometimes don't match

Whether to have very good solution

Or I used the wrong way (‘limit’ and ‘offset’ Parameter)!!!


Thank you for your answer.

"Graphics API" the existence of the cache?

i post a message and 46 comments.requests url, set the parameters:

offset=0&limit=1

Then it should return to the last comment (latest one), the actual return to the middle of a comment, and I tested a few times, set the offset and limit. According to the returned results, the middle one is the latest comment

If I set the limit value is greater than the 'comment.count', the returned data is all, the official website and facebook consistent

Because the cache reason?

Thanks again~

解决方案

@dbau - You are still better off using FQL. In my experience, unless you are making a very simple call, you have very little control over what you get via a Graph API call.

Why don't you want to use FQL? FQL is an endpoint of the Graph API. There is still some data that can only be returned via FQL.

This will get you the result you're looking for. The query needs to be URL encoded. I left it in plain text for clarity.

 https://graph.facebook.com/fql?access_token=[TOKEN]&q=
    SELECT id, fromid, text, time, likes, user_likes FROM comment
      WHERE object_id = [OBJECT_ID] ORDER BY time DESC LIMIT 0,[N]

You may find you don't get [N] comments returned each time, because Facebook filters out items that are not visible to the access_token owner after the query is run. You could either up the LIMIT and filter out any excess results returned or if you are using a user access_token, you could add AND can_like = TRUE to the WHERE clause to be guaranteed that, if they exist, [N] posts visible to the current user are returned.

这篇关于facebook graph api 评论列表排序,如'orderby=desc'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆