Kab*_*irB 11 facebook facebook-graph-api
随着Facebook发布了新的反应{NONE,LIKE,LOVE,WOW,HAHA,SAD,ANGRY}功能,但我无法弄清楚单个图形API请求中的所有反应计数.
有没有人想出办法在单个请求中获得每个帖子的详细反应?
Ant*_*lia 43
@CBroe引入的方法似乎使用多ID读取请求.
?IDS = 7175346442_10153799389241443,7175346442_10153799470326443&字段= reactions.type(爱).limit(0).总结(TOTAL_COUNT).如(reactions_love),reactions.type(WOW).limit(0).总结(TOTAL_COUNT).如(reactions_wow) ,reactions.type(HAHA).limit(0).总结(TOTAL_COUNT).如(reactions_haha),...
Facebook Graph API Explorer的屏幕截图:
一旦检索到一组帖子,就应该能够使用单个请求读取按类型分组的反应计数.注意,多ID读取请求模式中的ID的当前限制为50.
CBr*_*roe 12
理论上可以将Field Expansion与Field Aliases结合使用,如下所示:
?fields=reactions.type(LIKE).limit(0).summary(1).as(like),
reactions.type(WOW).limit(0).summary(1).as(wow),
reactions.type(SAD).limit(0).summary(1).as(sad),…
Run Code Online (Sandbox Code Playgroud)
但在这方面似乎仍有一些缺陷; 我经常在测试时遇到"发生未知错误"; 在上面的查询中用1替换LIKE的限制值触发它...
小智 7
只需将以下内容用作图表查询的一部分即可
fbpageid/posts?fields=created_time,story,message,shares,reactions.type(LIKE).limit(0).summary(1).as(like),reactions.type(LOVE).limit(0).summary(1).as(love),reactions.type(HAHA).limit(0).summary(1).as(haha),reactions.type(WOW).limit(0).summary(1).as(wow),reactions.type(SAD).limit(0).summary(1).as(sad),reactions.type(ANGRY).limit(0).summary(1).as(angry)&limit=10
Run Code Online (Sandbox Code Playgroud)
因此,我将仅使用1个查询获得帖子ID,创建时间,故事,消息,分享计数,反应计数(当前6个反应).它也适用于APi v2.9
如果您有read_insights权限,您可以通过以下方式获得饲料或帖子的反应
fields=insights.metric(post_reactions_by_type_total).period(lifetime).as(post_reactions_by_type_total)
你会得到如下结果:
"name": "post_reactions_by_type_total",
"period": "lifetime",
"values": [
{
"value": {
"like": 10,
"love": 2,
"wow": 3,
"haha": 1,
"sorry": 1,
"anger": 2
}
}
],
Run Code Online (Sandbox Code Playgroud)
我发现了一种通过1个请求实现此目的的方法:
GET /{userId}?fields=
posts.as(like){reactions.type(LIKE).limit(0).summary(true)},
posts.as(love){reactions.type(LOVE).limit(0).summary(true)},
posts.as(wow){reactions.type(WOW).limit(0).summary(true)},
posts.as(haha){reactions.type(HAHA).limit(0).summary(true)},
posts.as(sad){reactions.type(SAD).limit(0).summary(true)},
posts.as(angry){reactions.type(ANGRY).limit(0).summary(true)},
posts.as(thankful){reactions.type(THANKFUL).limit(0).summary(true)}
Run Code Online (Sandbox Code Playgroud)
这样,您将收到7个帖子列表(每个响应一个).例:
{
"like": {
"data": [<list of posts>]
},
"love": {
"data": [<list of posts>]
},
"wow": {
"data": [<list of posts>]
},
"haha": {
"data": [<list of posts>]
},
"sad": {
"data": [<list of posts>]
},
"angry": {
"data": [<list of posts>]
},
"thankful": {
"data": [<list of posts>]
},
"paging": {
"previous": "...",
"next": "..."
},
"id": "<userId>"
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18371 次 |
| 最近记录: |