将 Facebook graphEdge 解析为数组 php sdk

Parse Facebook graphEdge as array php sdk

我正在尝试从 Facebook 获取用户好友数 php sdk v5。如何将响应解析为 php 数组或如何检索好友总数? ->asArray()(我与 getGraphUser 一起使用)似乎在 getGraphEdge 上不起作用。我不确定如何访问或转换它。

try {
      // Returns a `Facebook\FacebookResponse` object
      $response = $cfb->get('/me/friends?fields=id', $_SESSION['fb_token']);
        $friends = $response->getGraphEdge();
    } catch(Facebook\Exceptions\FacebookResponseException $e) {
      echo 'Graph returned an error: ' . $e->getMessage();
      //exit;
    } catch(Facebook\Exceptions\FacebookSDKException $e) {
      echo 'Facebook SDK returned an error: ' . $e->getMessage();
      //exit;
    }

Facebook\GraphNodes\GraphEdge Object
(
    [request:protected] => Facebook\FacebookRequest Object
        (
            [app:protected] => Facebook\FacebookApp Object
                (
                    [id:protected] => ****
                    [secret:protected] => ****
                )

            [accessToken:protected] => *****
            [method:protected] => GET
            [endpoint:protected] => /me/friends?fields=id
            [headers:protected] => Array
                (
                    [Content-Type] => application/x-www-form-urlencoded
                )

            [params:protected] => Array
                (
                )

            [files:protected] => Array
                (
                )

            [eTag:protected] => 
            [graphVersion:protected] => v2.2
        )

    [metaData:protected] => Array
        (
            [summary] => Array
                (
                    [total_count] => 468
                )

        )

    [parentEdgeEndpoint:protected] => 
    [subclassName:protected] => 
    [items:protected] => Array
        (
        )

)

提前致谢!

必须使用 getTotalCount() 方法。

https://developers.facebook.com/docs/php/GraphEdge/5.0.0#get-total-count