我正在开发一个获取用户生日日期的应用程序,但它仍然无法正常工作。最奇怪的是,当我调试这个应用程序时,它会抛出开发者 facebook 界面,它运行良好。所以我不知道为什么它不想工作。这是我获得生日的 php 代码:
<?php
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?fields=id,name,birthday', 'GET');
print_r($user_profile);
//echo "Name: " . $user_profile['name'];
} 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>';
}
?>
感谢任何人