dpmpa26468 2013-03-10 23:42
浏览 31
已采纳

尝试使用Facebook Graph API列出FB好友图片[关闭]

I'm trying to set up a call that will list out a certain number of a friends pictures for a logged in facebook user. It works to spit out the users' picture, but I cannot get the call for fb friends pictures. I'm sure you guys can solve this easily. Here is the code:

<?php

    if(!isset($_SESSION['logged_in']))
    {
        ?>


<?php
    }
    else{


        if (!class_exists('FacebookApiException')) {
            require_once('./src/facebook.php' );
        }
        $facebook = new Facebook(array(
                                       'appId' => $appId,
                                       'secret' => $appSecret,
                                       ));


        $fbuser = $facebook->getUser();

        echo $fbuser;

        echo $_SESSION['user_name'];
        echo '<img src="https://graph.facebook.com/'.$fbuser.'/picture">';

        echo '<img src="https://graph.facebook.com/'.$fbuser.'/friends/picture">';



        echo '<a href="?logout=1">Log Out</a>';
    }
    ?>
  • 写回答

1条回答 默认 最新

  • dongtang1910 2013-03-11 01:00
    关注

    You first need to get a list of the user friends calling /me?fields=friends. Then, you can only add their id to the picture urls just like you did with the user:

    <img src="https://graph.facebook.com/{{friend_id}}/picture">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 MATLAB联合adams仿真卡死如何解决(代码模型无问题)
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决
  • ¥15 python中transformers可以正常下载,但是没有办法使用pipeline
  • ¥50 分布式追踪trace异常问题
  • ¥15 人在外地出差,速帮一点点
  • ¥15 如何使用canvas在图片上进行如下的标注,以下代码不起作用,如何修改