我有一个典型的实现,让你得到Facebook帖子的每个反应的计数,然后我在Facebook Live事件上广播这些结果。 这非常有效,但我想得到每个反应的完整计数,包括那些来自共享帖子的人,当其他粉丝分享我的帖子以增加覆盖面时,通常会发生这种情况,并且人们会加入对此的反应"共享内容& #34;而不是在我的帖子中,所以我无法获得这些反应。
我知道这些数据存在,因为如果可以在我的帖子洞察中看到(当你是粉丝专页的管理员时)
这是我的代码:
function refreshCounts(postID,access_token) {
var reactions = ['LIKE', 'LOVE', 'WOW', 'HAHA', 'SAD', 'ANGRY'].map(function (e) {
var code = 'reactions_' + e.toLowerCase();
return 'reactions.type(' + e + ').limit(0).summary(total_count).as(' + code + ')'
}).join(',');
var defaultCount = 0;
var v1 = $('.like .counter'),
v2 = $('.love .counter'),
v3 = $('.sad .counter'),
v4 = $('.haha .counter'),
v5 = $('.angry .counter'),
v6 = $('.shock .counter');
var url = 'https://graph.facebook.com/v2.8/?ids=' + postID + '&fields=' + reactions + '&access_token=' + access_token;
$.getJSON(url, function(res){
v1.text(defaultCount + res[postID].reactions_like.summary.total_count);
v2.text(defaultCount + res[postID].reactions_love.summary.total_count);
v3.text(defaultCount + res[postID].reactions_sad.summary.total_count);
v4.text(defaultCount + res[postID].reactions_haha.summary.total_count);
v5.text(defaultCount + res[postID].reactions_angry.summary.total_count);
v6.text(defaultCount + res[postID].reactions_wow.summary.total_count);
});
}
这是一个请求的示例:
{
"9746288590_10154416270033591": {
"reactions_like": {
"data": [
],
"summary": {
"total_count": 107
}
},
"reactions_love": {
"data": [
],
"summary": {
"total_count": 22
}
},
"reactions_wow": {
"data": [
],
"summary": {
"total_count": 274
}
},
"reactions_haha": {
"data": [
],
"summary": {
"total_count": 1839
}
},
"reactions_sad": {
"data": [
],
"summary": {
"total_count": 7
}
},
"reactions_angry": {
"data": [
],
"summary": {
"total_count": 1
}
},
"id": "9746288590_10154416270033591"
}
}
有什么想法吗?谢谢