尽管没有更多数据,但Facebook Graph API JSON结果具有Page Next [英] Facebook Graph API JSON result has Page Next, despite no more data

查看:125
本文介绍了尽管没有更多数据,但Facebook Graph API JSON结果具有Page Next的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道这是Facebook错误还是我做错了什么.无论如何,我正在开发一个服务器应用程序,它通过Graph API调用与我自己的简单Facebook应用程序对话.出于开发目的,Facebook应用程序的唯一用户是我定义的一些 Test Users .在这种情况下,我有一个测试用户"Lisa Mills",我想返回她的朋友列表.她唯一的朋友是约翰·史密斯".我使用Graph API HTTPS调用来检索她的朋友列表,像这样(链接可能不再可用,但出于说明目的将其发布在这里):

I am wondering if this is a Facebook bug or something that I am doing wrong. Anyways, I am developing a server application that talks to my own simple Facebook app via Graph API calls. For development purposes, the only users of the Facebook app are a few Test Users that I have defined. In this scenario, I have one test user "Lisa Mills" and I want to return a list of her friends. Her only friend is "John Smith". I use the Graph API HTTPS call for retreiving her list of friends, like so (links probably won't work anymore, but they are posted here for illustrative purposes):

https://graph.facebook.com/100004330990794/friends?access_token=AAAGGG3niQkQBAPne8jGOcfZAUZCiqbgDMAPV0QlA5GMGorFdEZCOBAX3daZAOkcWmenyfFwYzuBCxrE2gEOXaZAa7tJptZBE826vvHdw7JtCZB0If9mJ041

结果数据:

{
   "data": [
      {
         "name": "John Smith",
         "id": "100004375356845"
      }
   ],
   "paging": {
      "next": "https://graph.facebook.com/100004330990794/friends?access_token=AAAGGG3niQkQBAPne8jGOcfZAUZCiqbgDMAPV0QlA5GMGorFdEZCOBAX3daZAOkcWmenyfFwYzuBCxrE2gEOXaZAa7tJptZBE826vvHdw7JtCZB0If9mJ041&limit=5000&offset=5000&__after_id=100004375356845"
   }
}

令人困惑的是,为什么JSON响应包含下一页"值,因为Lisa不会有其他任何朋友要返回.无论如何,如果我转到JSON中指定的URI,则会收到以下响应:

What is puzzling is why the JSON response contains a "next page" value because Lisa is not going to have any other friends to return. Anyways, if I go to the URI specified in the JSON, I receive this response:

{
   "data": [
   ],
   "paging": {
      "previous": "https://graph.facebook.com/100004330990794/friends?limit=5000&offset=0&access_token=AAAGGG3niQkQBAPne8jGOcfZAUZCiqbgDMAPV0QlA5GMGorFdEZCOBAX3daZAOkcWmenyfFwYzuBCxrE2gEOXaZAa7tJptZBE826vvHdw7JtCZB0If9mJ041"
   }
}

当然...不返回任何数据.我自然会假设,如果Lisa拥有5000多个朋友,则该下一页"应该仅包含其他数据.这是Facebook Graph API中的错误,还是我的服务器应用程序需要正常处理而没有错误?

Of course...no data is returned. I would naturally presume that this "next page" should only have additional data if Lisa had over 5000 friends. Is this a bug in Facebook's Graph API, or is this a normal situation that my server application needs to handle without error?

推荐答案

我自然会假设,如果Lisa拥有超过5000个朋友,则该下一页"应该仅具有其他数据.这是Facebook Graph API中的错误,还是我的服务器应用程序需要正常处理而没有错误?

I would naturally presume that this "next page" should only have additional data if Lisa had over 5000 friends. Is this a bug in Facebook's Graph API, or is this a normal situation that my server application needs to handle without error?

在最近的开发者博客中条目,Facebook表示他们已修正"了该API的一些部分:

In a recent developer blog entry, Facebook said they had "fixed" this for some parts of the API:

对于选定的边缘,我们引入了基于光标的偏移分页.这项改进可以明确表明您何时到达数据集的末尾.没有新数据时,我们将不再显示上一个"或下一个"分页链接.这样可以缩短请求处理时间,每次翻阅整个集合时都可以节省一次往返.我们正在努力增加对更多边缘的支持."

看起来/user/friends连接不是选定边" 之一...

Looks like the /user/friends connection is not one of those "selected edges" yet …

这篇关于尽管没有更多数据,但Facebook Graph API JSON结果具有Page Next的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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