我想在Facebook帖子上计算喜欢(和评论)的数量。但是当帖子上有超过25个喜欢的时候,结果会像这样分页:
stdClass Object ( [data] => Array ( [0] => stdClass Object ( [id] => 802020049912534 [name] => Sagar Lama ) [1] => stdClass Object ( [id] => 590020061101130 [name] => Sheguey Squaad ) [2] => stdClass Object ( [id] => 696207733846316 [name] => Ossama Barcalona ) [3] => stdClass Object ( [id] => 1901218896769448 [name] => Gab Alviola ) [4] => stdClass Object ( [id] => 407069606150738 [name] => Thongloy Thichanon ) [5] => stdClass Object ( [id] => 947084195347741 [name] => Thomas Vujić ) [6] => stdClass Object ( [id] => 1614068872196230 [name] => เพื่à¸à¸™à¸à¸¹à¹€à¸ˆà¹‡à¸š ชีวิตมึงจบ ) [7] => stdClass Object ( [id] => 1431328280529413 [name] => Ali-Bilal Dernek ) [8] => stdClass Object ( [id] => 855095404568872 [name] => Henry Feng ) [9] => stdClass Object ( [id] => 937460179628960 [name] => Rex Lu ) [10] => stdClass Object ( [id] => 1627484497506023 [name] => Röbërt GärÄïâ ) [11] => stdClass Object ( [id] => 971640236220159 [name] => Reyjoel Jimeno ) [12] => stdClass Object ( [id] => 1644471585776456 [name] => Og Catwalk ) [13] => stdClass Object ( [id] => 1652037021731712 [name] => Rafik Benchibane ) [14] => stdClass Object ( [id] => 499561140196412 [name] => Lizy Smith ) [15] => stdClass Object ( [id] => 10207169299621544 [name] => Ngai Lam ) [16] => stdClass Object ( [id] => 505507699598850 [name] => Ëlloï Gonzalez Sanchez ) [17] => stdClass Object ( [id] => 802078276575586 [name] => Armando Sanchez ) [18] => stdClass Object ( [id] => 10205977306769395 [name] => Fredy Santizo ) [19] => stdClass Object ( [id] => 811409772291367 [name] => Malik Davis ) [20] => stdClass Object ( [id] => 842376069172521 [name] => Isak Renee Martinez ) [21] => stdClass Object ( [id] => 915675738506394 [name] => Kimora Stephens Davis ) [22] => stdClass Object ( [id] => 916531748393520 [name] => Isabel Averill ) [23] => stdClass Object ( [id] => 941049645918044 [name] => Mathias Tenezaca Mendez ) [24] => stdClass Object ( [id] => 1452189318420627 [name] => Andrew Hernandez ) ) [paging] => stdClass Object ( [cursors] => stdClass Object ( [after] => MTQ1MjE4OTMxODQyMDYyNw== [before] => ODAyMDIwMDQ5OTEyNTM0 ) [next] => https://graph.facebook.com/v2.3/15087023444_10153196470723445/likes?access_token=xxxxxxxxxxxxxxxxxxx&limit=25&after=MTQ1MjE4OTMxODQyMDYyNw%3D%3D ) )
如果不过多地询问Facebook API,我如何计算给定帖子的喜欢和评论。我正在使用PHP SDK
答案 0 :(得分:1)
您可以使用分页来浏览所有“赞”,也可以使用摘要参数来获取总数:
/post-id?fields=likes.summary(true)
部分回复:
"summary": {
"total_count": 393,
"can_like": true,
"has_liked": false
}