我尝试用facebook登录,我构建了这段代码:
<?php
ob_start();
include("facebook_constants.php"); // in this file i have appid and appsecretid
$users = $facebook->getUser();
if ($users!="") {
try {
$user_profile = $facebook->api('/me','GET');
$logoutUrl = $facebook->getLogoutUrl();
$fuserid=$user_profile["id"]; // give me the id of the user
$fusername=$user_profile["name"]; // give me the name of the user
$femail=$user_profile["email"]; // give me the email of the user
$fusernamenew = str_replace(' ', '', $fusername); // change the name to username (omer lol = omerlol)
$newtoken=base64_encode($fuserid."::".$fusernamenew."::".$femail); // data to token
$itsme = $this->haimz->DB->num_rows("SELECT id FROM users WHERE fbid = ?haimz?", $fuserid); // if have user with that id = login , if not goto register page
if($itsme > 0){
echo "goto login page";
}
else{
echo "goto register page";
exit;
}
} catch (FacebookApiException $e) {
$users = null;
}
}
?>
答案 0 :(得分:0)
https://developers.facebook.com/docs/apps/changelog
为了更好地保护人们的信息,当人们登录已升级为使用Graph API v2.0的应用程序版本时,Facebook现在会发布应用程序范围的ID而不是该人的原始ID。但是,对于之前登录过您应用的用户,用户ID不会更改。
出于隐私原因,您不再获得用户的“真实”ID。您只能获得仅在应用程序中唯一的App Scoped ID。当用户使用App Scoped ID返回您的应用程序时,您仍然可以使用它来识别用户,它只会在另一个应用程序中有所不同。
如果需要,您还可以使用Business Mapping API在不同应用之间映射App Scoped ID:https://developers.facebook.com/docs/apps/for-business