为什么好友列表中的 total_count 与 facebook 图表中的实际好友数不同
Why total_count in friendlist is different from actual number of friends count from facebook graph
我从 facebook 获取好友列表:
$send_url = "https://graph.facebook.com/me/friends?access_token=CAATihlnybnYBALlxCHkgcnVxQ7HvZAyPYqBMWHtBfdLizNZBzIffMBFBfVBzZCDCvOXuZBzbTDcRd36xfwwtSghQBM6rZB14bL4FjhHRcX0ZAIYt3oi3ShbqAEU4aXZAjHD4MtYSQmHsq8RR0uEz4ZBfk2hD1GLctLZAzifTcQGwg26D0AQZBBvD1FkEFgUWhu1YaXZCwTojHwe4AZDZD";
然后我通过以下方式统计朋友:
$jsonFriends = json_decode($data, true);
$friendsLists = $jsonFriends['data'];
$i=0;
foreach ($friendsLists as $friends)
{
$i=$i+1;
}
echo $i;
我得到的 $i 是朋友的数量:453,但是如果 access_token 过期,我没有得到数据,但它仍然给出 total_count 的摘要是 474。
所以我想知道 474 是什么意思?这是朋友总数吗(我在我的facebook页面上查看,所有朋友,数量也是474)。那为什么我的计数会给出不同的数字呢?我对计数很有信心,因为我给出了较短的测试数据,我可以仔细检查它并看到它计数正确。
/{user-id}/friends 的 documentation 指出:
- This will only return any friends who have used (via Facebook Login) the app making the request.
- If a friend of the person declines the user_friends permission, that friend will not show up in the friend list for this person.
这可能解释了为什么 data
对象中返回的人数与 total_count
不同:
"summary": {
"total_count": 474
}
其中 returns Facebook 好友总数,无论他们是否拥有该应用程序。
这可能是您列表中缺少的 21 人的原因。
我从 facebook 获取好友列表:
$send_url = "https://graph.facebook.com/me/friends?access_token=CAATihlnybnYBALlxCHkgcnVxQ7HvZAyPYqBMWHtBfdLizNZBzIffMBFBfVBzZCDCvOXuZBzbTDcRd36xfwwtSghQBM6rZB14bL4FjhHRcX0ZAIYt3oi3ShbqAEU4aXZAjHD4MtYSQmHsq8RR0uEz4ZBfk2hD1GLctLZAzifTcQGwg26D0AQZBBvD1FkEFgUWhu1YaXZCwTojHwe4AZDZD";
然后我通过以下方式统计朋友:
$jsonFriends = json_decode($data, true);
$friendsLists = $jsonFriends['data'];
$i=0;
foreach ($friendsLists as $friends)
{
$i=$i+1;
}
echo $i;
我得到的 $i 是朋友的数量:453,但是如果 access_token 过期,我没有得到数据,但它仍然给出 total_count 的摘要是 474。 所以我想知道 474 是什么意思?这是朋友总数吗(我在我的facebook页面上查看,所有朋友,数量也是474)。那为什么我的计数会给出不同的数字呢?我对计数很有信心,因为我给出了较短的测试数据,我可以仔细检查它并看到它计数正确。
/{user-id}/friends 的 documentation 指出:
- This will only return any friends who have used (via Facebook Login) the app making the request.
- If a friend of the person declines the user_friends permission, that friend will not show up in the friend list for this person.
这可能解释了为什么 data
对象中返回的人数与 total_count
不同:
"summary": {
"total_count": 474
}
其中 returns Facebook 好友总数,无论他们是否拥有该应用程序。 这可能是您列表中缺少的 21 人的原因。