【发布时间】:2012-03-24 14:55:27
【问题描述】:
我正在尝试通过 Facebook 图形 api 检索信息,使用下面的代码没有返回任何内容,我在从在线文档等获得帮助后编写了此代码,但它不起作用。
请帮我解决这个问题。
include ('src/facebook.php');
$app_id = "160336957418730";
$app_secret = "************************";
$facebook = new Facebook( array('appId' => $app_id, 'secret' => $app_secret, ));
$user = $facebook -> getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook -> api('/me');
//$user_profile = $facebook->api('/me/home');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
echo $user_profile[name];
echo $user_profile[id];
echo $user_profile[picture];
我把它们都用了,但没有任何效果。
【问题讨论】:
标签: php facebook facebook-graph-api facebook-php-sdk facebook-authentication