我尝试与 Facebook connect 建立连接,但出现了一些错误。
进一步的 Facebook 登录 Javascript 错误
我对这个链接有类似的问题。Php $_COOKIE 没有找到相关的 cookie
Notice: Undefined index: fbs_appID in /opt/lampp/htdocs/phpdeneme/index.php on line 10
Notice: Undefined index: sig in /opt/lampp/htdocs/phpdeneme/index.php on line 22
Warning: file_get_contents(https://graph.facebook.com/me?access_token=) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request in /opt/lampp/htdocs/phpdeneme/index.php on line 30
<?php
define('FACEBOOK_APP_ID', 'APP_ID');
define('FACEBOOK_APP_SECRET','SECRET_ID');
function get_facebook_cookie($appID,$appSecret){
$args = array();
parse_str(trim($_COOKIE['fbs_' . $appID], '\\"'), $args);
ksort($args);
$payload = '';
foreach($args as $key=>$value){
if($key != 'sig'){
$payload .= $key . '=' . $value;
}
}
if(md5($payload . $appSecret) != $args['sig'])
return null;
return $args;
}
$cookie = get_facebook_cookie(FACEBOOK_APP_ID, FACEBOOK_APP_SECRET);
$user = json_decode(file_get_contents('https://graph.facebook.com/me?access_token=' . $cookie['access_token']));
?>
<html>
<body>
<?php if($cookie){ ?>
Welcome <?= $user->name ?>
<?php } else { ?>
<fb: login-button></fb:login-button>
<?php } ?>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({appId: '<?= FACEBOOK_APP_ID ?>' , status: true, cookie: true, xfbml:true});
FB.Event.subscribe('auth.login',function(response){
window.location.reload();
});
</script>
</body>
</html>
怎么了 ?少了什么东西 ?什么 fbs cookie 没有创建?