当我尝试让用户发帖时,它只显示“数组([数据] => 数组())”(配置文件显示,我可以发布到墙上)。当我将“我”更改为公共页面时,它会起作用。登录链接和用户信息显示。请帮助我,我不明白为什么它不起作用!
<?php
session_start();
require 'facebook/facebook-php-sdk/src/facebook.php';
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => 'xxxxxxxxxxxxxxxxxxxxxxx',
'secret' => 'xxxxxxxxxxxxxxxxxxxxxxx',
));
// Get User ID
$user = $facebook->getUser();
if ($user)
{
$url = $facebook->getLogoutUrl();
}
else
{
$url = $facebook->getLoginUrl();
}
if ($user) {
try {
$pageFeed = $facebook->api('me' . '/feed');
print_r($pageFeed);
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
?>
<a href="<?php echo $url; ?>">LOGIN!</a>
<pre><?php print_r($user_profile); ?></pre>