您好,当用户登录网站时,我正在努力获取用户的位置。我想得到城市和国家。这是我的代码。
require 'src/facebook.php'; // Include facebook SDK file
// Include functions
$facebook = new Facebook(array(
'appId' => '446287188809548', // Facebook App ID
'secret' => '5210aae00c4f11eca8451a9da9be4aaf', // Facebook App Secret
'cookie' => true,
));
$user = $facebook->getUser();
if ($user) {
try {
$user_profile = $facebook->api('/me');
$fbid = $user_profile['id']; // To Get Facebook ID
$fbuname = $user_profile['username']; // To Get Facebook Username
$fbfullname = $user_profile['name']; // To Get Facebook full name
$femail = $user_profile['email']; // To Get Facebook email ID
// checkuser($fbid,$fbuname,$fbfullname,$femail); // To update local DB
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
if ($user) {
$logoutUrl = $facebook->getLogoutUrl(array(
'next' => 'http://websoftit.ro/lackoflove/logout.php', // Logout URL full path
));
} else {
$loginUrl = $facebook->getLoginUrl(array(
'scope' => 'email', // Permissions to request from the user
));
}