我正在制作一个 facebook 应用程序来显示用户的生日......
<?
require_once('php-sdk/facebook.php');
$config = array(
'appId' => 'YOUR_APP_ID',
'secret' => 'YOUR_APP_SECRET',
);
$facebook = new Facebook($config);
$user_id = $facebook->getUser();
?>
<html>
<head></head>
<body>
<?
if($user_id)
{
// We have a user ID, so probably a logged in user.
// If not, we'll get an exception, which we handle below.
try
{
$user_profile = $facebook->api('/me','GET');
echo "Name: " . $user_profile['name'];
// Birth Date to be printed here........
echo "DOB: ".$user_profile['birthday'];
}
catch(FacebookApiException $e)
{
// If the user is logged out, you can have a
// user ID even though the access token is invalid.
// In this case, we'll get an exception, so we'll
// just ask the user to login again here.
$login_url = $facebook->getLoginUrl();
echo 'Please <a href="' . $login_url . '">login.</a>';
error_log($e->getType());
error_log($e->getMessage());
}
}
else
{
// No user, print a link for the user to login
$login_url = $facebook->getLoginUrl();
echo 'Please <a href="' . $login_url . '">login.</a>';
}
?>
</body>
</html>
现在,问题是This prints the name as expected but prints nothing in place on date of birth
......当我进一步提到时,我听说了 facebook 权限(扩展)这个术语......并从以下链接
http://developers.facebook.com/docs/reference /api/用户/
我发现我们需要启用权限users_birthday
或friends_birthday
.
现在,我们如何在 php 代码中启用它?...请提供样品帮助.......如果这个问题看起来很愚蠢,我很抱歉。我只是 facebook 应用程序开发的新手,也是 php 的初学者……我尝试了 stackoverflow.com 中的其他示例,但对我没有多大帮助……