doulandai0641 2014-08-19 16:47
浏览 52

无法在PHP SDK中获得Facebook好友

I want to get facebook friends using php SDK. I cannot use Latest PHP SDK as it is using namespaces and my application doesn't support namespaces. I get following permissions from user

email,user_birthday,user_status,publish_stream,offline_access,user_friends

And when the code is executed, it shows the following Facebook OATH Dialogue

enter image description here

And you can see in the image that it doens't show user friends permission.

And when I want to get user's friends using PHP SDK using following code:

    require_once(APPLICATION_PATH_LIB . "/Facebook/facebook.php");
    $facebook = new Facebook(array('appId' => $appId, 'secret' => $appSecret));
    $token_url = "https://graph.facebook.com/oauth/access_token?" .
            "client_id=" . $appId .
            "&client_secret=" . $appSecret .
            "&grant_type=client_credentials";
    $app_token = file_get_contents($token_url);
    $app_token = explode("=", $app_token);

    $app_token = $app_token[1];

    $user = $facebook->getUser();



    if ($user) {

        $user_profile = $facebook->api('/me', array('access_token' => $app_token));
        //echo '<pre>';var_dump($user_profile);die;
        $friends = $facebook->api('/me/friends', array('access_token' => $app_token));

       echo '<pre>';print_r($friends);
    }

And it is giving me following error

OAuthException: An active access token must be used to query information about the current user.
  • 写回答

2条回答 默认 最新

  • duanhuizhe6767 2014-08-19 16:57
    关注

    They actually disabled this relatively recently---

    You can now only get a list of facebook friends who are also using your app.

    See this GraphAPI reference

    (Second point under "Permissions")

    There seems to be some disagreement about this, but, according to @drmarvelous, you can get the users' full list of friends if you submit your application for review and request that permission through the "Status & Review" section under your app. But, this process can take some time, and you may not even be granted the permission --

    评论

报告相同问题?

悬赏问题

  • ¥20 c语言写的8051单片机存储器mt29的模块程序
  • ¥60 求直线方程 使平面上n个点在直线同侧并且距离总和最小
  • ¥50 java算法,给定试题的难度数量(简单,普通,困难),和试题类型数量(单选,多选,判断),以及题库中各种类型的题有多少道,求能否随机抽题。
  • ¥50 rk3588板端推理
  • ¥250 opencv怎么去掉 数字0中间的斜杠。
  • ¥15 这种情况的伯德图和奈奎斯特曲线怎么分析?
  • ¥250 paddleocr带斜线的0很容易识别成9
  • ¥15 电子档案元素采集(tiff及PDF扫描图片)
  • ¥15 flink-sql-connector-rabbitmq使用
  • ¥15 zynq7015,PCIE读写延时偏大