如何使用Facebook图形API显示用户个人资料图片?

问题描述:

我想在我的应用程序画布页面中显示用户个人资料图片,有没有办法使用图形API?

I would like to display the users profile picture inside of my applications canvas page, is there a way to do that using the graph api?

我知道我可以使用FBML,但我也想将配置文件图片传递给我正在制作的Flash游戏,所以我必须从api获取配置文件图片并将其作为变量发送,这里是我迄今为止的代码,

I know I can do it using FBML but I would also like to pass the profile pic to a flash game I am making, so I would have to get the profile pic from the api and send it as a variable, here is the code I have thus far,

$facebook = new Facebook(array(
    'appId'  => FACEBOOK_APP_ID,
    'secret' => FACEBOOK_SECRET_KEY,
    'cookie' => true,
    'domain' => 'myurl/facebook-test'
));

$session = $facebook->getSession();

        $uid = $facebook->getUser();
        $me = $facebook->api('/me');

        $updated = date("l, F j, Y", strtotime($me['updated_time']));

        echo "Hello " . $me['name'] . $me['picture'] . "<br />";
  echo "<div style=\"background:url(images/bg.jpg); width:760px; height:630px;\">" . "You last updated your profile on " . $updated . "</div>" . "<br /> your uid is" . $uid;

$ me ['picture'] 似乎没有工作,但我仍然非常新颖的图形api,我可能会做一些非常业余的错误!

$me['picture'] does not seem to be working, but I am still very new to the graph api, and I am probably making a few very amateur mistakes!

知道用户ID的个人资料图片的URL为: -

Knowing the user id the URL for their profile picture is:-

http://graph.facebook.com/[UID]/picture

代替[UID]你放置$ uid变量, URL可以传递给flash

where in place of [UID] you place your $uid variable, and that URL can be passed to flash