Php 无法获取好友总数-Facebook
我是用户Php 无法获取好友总数-Facebook,php,facebook-graph-api,facebook-php-sdk,Php,Facebook Graph Api,Facebook Php Sdk,我是用户PHP facebook API,用于获取facebook的用户数据。我正试图得到所有的朋友 我正在使用图形API,它返回以下内容: { "id": "12312312312312", "name": "myName", "friends": { "data": [ ], "summary": { "total_count": 89 } } } 但当我使用代码时: $profile_request = $fb->
PHP facebook API
,用于获取facebook的用户数据。我正试图得到所有的朋友
我正在使用图形API
,它返回以下内容:
{
"id": "12312312312312",
"name": "myName",
"friends": {
"data": [
],
"summary": {
"total_count": 89
}
}
}
但当我使用代码时:
$profile_request = $fb->get('/me?fields=name, friends');
$profile = $profile_request->getGraphNode()->asArray();
print_r($profile);
//It return these to me:
Array ( [name] => Myname [friends] => Array ( ) [id] => 12346677888 )
友元数组只向我返回空值
如何取回总计数
thx帮助Facebook v2.0升级版,您可以像这样尝试“用户朋友”
我知道这是一个老问题,但这可能对某些人有帮助,因为我只是在自己寻找答案。我找到了 您必须在无阵列的情况下获取图形节点才能获取总计数
$total_count = $getGraphNode['friends']->getMetaData()['summary']['total_count'];
例如:
$getGraphNode = $profileRequest->getGraphNode();
$profile = $getGraphNode->asArray();
$profile的作用是相同的,但现在您将拥有不带asArray的graph节点,因此您可以获取总计数
$total_count = $getGraphNode['friends']->getMetaData()['summary']['total_count'];