无法向字段参数添加点赞

发布于 2024-12-01 21:24:31 字数 1454 浏览 0 评论 0原文

根据 Facebook Graph API 文档fields 参数充当结果掩码:

默认情况下,当您进行查询时,会返回大多数对象属性。 您可以选择要返回的字段(或连接) “fields”查询参数。

事实上,这对于大多数领域都适用。例如,/7354446700?fields=name,picture 返回:

{
  "name": "Grooveshark", 
  "id": "7354446700", 
  "type": "page", 
  "picture": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/203560_7354446700_6819703_q.jpg"
}

但是,由于某种原因,一旦 likes 字段添加到 fields > 列出来,事情就崩溃了。例如, /7354446700?fields=name,picture,likes 返回:

{
  "name": "Grooveshark", 
  "id": "7354446700", 
  "type": "page", 
  "picture": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/203560_7354446700_6819703_q.jpg", 
  "likes": {
    "data": [
    ]
  }
}

更奇怪的是,如果我省略其他两个字段(namepictures),只发送喜欢,我发现

{
  "likes": {
    "data": [
    ]
  }
}

这个额外奇怪的原因是因为“强制”字段(idtype)应该添加哪些内容这里并未包含所有回复(尽管在 fields=name,picture,likes包含)。

似乎发生的情况是,field=likes 参数似乎被误解为连接请求,而不仅仅是一个字段掩码,因此 data 当您致电 /7354446700/likes 时通常会出现的片段。

这有充分的理由吗?有没有其他方法可以在不获取整个对象的情况下获取 likes 字段?我无法想象这是预期的行为,所以我认为这是一个错误,但我想在提交错误之前我应该​​先在这里询问。

According to the Facebook Graph API documentation, the fields param acts as a result mask:

By default, most object properties are returned when you make a query.
You can choose the fields (or connections) you want returned with the
"fields" query parameter.

Indeed, this works fine for most fields. For instance, /7354446700?fields=name,picture returns:

{
  "name": "Grooveshark", 
  "id": "7354446700", 
  "type": "page", 
  "picture": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/203560_7354446700_6819703_q.jpg"
}

However, for some reason, as soon as the likes field is added to the fields list, things break down. For instance, /7354446700?fields=name,picture,likes returns:

{
  "name": "Grooveshark", 
  "id": "7354446700", 
  "type": "page", 
  "picture": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/203560_7354446700_6819703_q.jpg", 
  "likes": {
    "data": [
    ]
  }
}

Even more strange, if I omit the other two fields (name and pictures), sending only likes, I get

{
  "likes": {
    "data": [
    ]
  }
}

The reason I find this extra-strange is because the "mandatory" fields (id and type) which should be added to every response are not included here (although they were included when fields=name,picture,likes).

What appears to be happening is that the field=likes parameter appears to be misinterpreted as a Connections request rather than simply a field mask, hence the data segment that normally appears when you'd call /7354446700/likes.

Is there a good reason for this? Is there any other way to get the likes field without fetching the entire object? I can't imagine this would be expected behavior, so I assume it is a bug, but I thought I'd ask here first before filing one.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏至、离别 2024-12-08 21:24:31

这确实是一个错误;我已经进行了内部检查,发现有一个尚未解决的任务可以解决此问题,该问题之前已在错误跟踪器中向我们报告过。

同时,页面的默认返回值将包含“喜欢”字段,即使无法单独检索该字段。

This indeed appears to be a bug; I've checked internally and there's an as yet unresolved task open to fix this issue which was reported to us in our bug tracker previously.

In the meantime, the default return value for a page will include the 'likes' field even if it cant be retrieved solely.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文