我想知道这是 Facebook 的错误还是我做错了什么。不管怎样,我正在开发一个服务器应用程序,它通过 Graph API 调用与我自己的简单 Facebook 应用程序进行对话。出于开发目的,Facebook 应用程序的唯一用户是我定义的一些测试用户。在这种情况下,我有一个测试用户“Lisa Mills”,我想返回她的 friend 列表。她唯一的 friend 是“约翰·史密斯”。我使用 Graph API HTTPS 调用来检索她的 friend 列表,如下所示(链接可能不再有效,但出于说明目的将它们发布在此处):
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 不会返回任何其他 friend 。无论如何,如果我转到 JSON 中指定的 URI,我会收到以下响应:
{
"data": [
],
"paging": {
"previous": "https://graph.facebook.com/100004330990794/friends?limit=5000&offset=0&access_token=AAAGGG3niQkQBAPne8jGOcfZAUZCiqbgDMAPV0QlA5GMGorFdEZCOBAX3daZAOkcWmenyfFwYzuBCxrE2gEOXaZAa7tJptZBE826vvHdw7JtCZB0If9mJ041"
}
}
当然...没有数据返回。我自然会认为,如果 Lisa 有超过 5000 个 friend ,这个“下一页”就应该有额外的数据。这是 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?
在最近的developer blog entry中,Facebook 表示他们已针对 API 的某些部分“修复”了此问题:
“For selected edges, we’ve introduced cursor-based offset paging. This improvement definitively indicates when you've reached the end or beginning of a data set. We'll no longer show the ‘previous’ or 'next' paging links when there's no new data. This translates to faster request processing times, saving you one round-trip every time you page through an entire collection. We're working on adding support for more edges.”
看起来/user/friends
连接还不是那些“选定边缘”之一......
关于json - Facebook Graph API JSON 结果具有“下一页”,尽管没有更多数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12502080/