显示用户个人资料图片

显示用户个人资料图片

本文介绍了如何使用 facebook graph 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

这篇关于如何使用 facebook graph api 显示用户个人资料图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 18:55