我使用PHP已經安裝Facebook的身份驗證,它是這樣的 首先獲得授權在這裏:Facebook驗證/登錄麻煩
https://graph.facebook.com/oauth/authorize?client_id=<?= $facebook_app_id ?>&redirect_uri=http://www.example.com/facebook/oauth/&scope=user_about_me,publish_stream
然後獲得訪問令牌這裏:
$url = "https://graph.facebook.com/oauth/access_token?client_id=".$facebook_app_id."&redirect_uri=http://www.example.com/facebook/oauth/&client_secret=".$facebook_secret."&code=".$code;"
function get_string_between($string, $start, $end){
$string = " ".$string;
$ini = strpos($string,$start);
if ($ini == 0) return "";
$ini += strlen($start);
$len = strpos($string,$end,$ini) - $ini;
return substr($string,$ini,$len);
}
$access_token = get_string_between(file_get_contents($url), "access_token=", "&expires=");
然後獲取用戶信息:
$facebook_user = file_get_contents('https://graph.facebook.com/me?access_token='.$access_token);
$facebook_id = json_decode($facebook_user)->id;
$first_name = json_decode($facebook_user)->first_name;
$last_name = json_decode($facebook_user)->last_name;
這很醜陋(我ñ我的意見),但它的作品....如何......用戶仍然沒有登錄...因爲我沒有創建或檢索任何會話變量,以確認用戶登錄到Facebook ...
這意味着要讓完成使用仍然有登錄認證後....
第一:有沒有使用PHP做我上面那樣一個更好的辦法? 第二:如何設置/獲取會話變量/餅乾是確保不必須點擊用戶登錄
感謝您的幫助