我使用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做我上面那样一个更好的办法? 第二:如何设置/获取会话变量/饼干是确保不必须点击用户登录
感谢您的帮助