我仍然试图让我的网站使用Facebook Connect。我一直在使用指南here。WAMP与Live服务器的facebook连接
下面的代码是从本地主机(我的应用程序ID和秘密ID已被删除)运行:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?php
define('YOUR_APP_ID', '**MY APP ID**');
define('YOUR_APP_SECRET', '**MY SECRET APP ID**');
$cookie = get_facebook_cookie(YOUR_APP_ID, YOUR_APP_SECRET);
function get_facebook_cookie($app_id, $app_secret) {
$args = array();
parse_str(trim($_COOKIE['fbs_' . $app_id], '\\"'), $args);
ksort($args);
$payload = '';
foreach ($args as $key => $value) {
if ($key != 'sig') {
$payload .= $key . '=' . $value;
}
}
if (md5($payload . $app_secret) != $args['sig']) {
return null;
}
return $args;
}
$user = json_decode(file_get_contents(
'https://graph.facebook.com/me?access_token=' .
$cookie['access_token']));
?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<?php if ($cookie) { ?>
<li> Welcome <?= $user->name ?></li>
<?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: '<?= **MY APP ID** ?>', status: true,
cookie: true, xfbml: true});
FB.Event.subscribe('auth.login', function(response) {
window.location.reload();
});
</script>
</html>
,但给我下面的错误,当我尝试通过WAMP运行它:
Notice: Undefined index: fbs_**MY APP ID** in C:\wamp\www\fbtest.php on line 12
Notice: Undefined index: sig in C:\wamp\www\fbtest.php on line 20
Warning: file_get_contents() [function.file-get-contents]: Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in C:\wamp\www\fbtest.php on line 30
Warning: file_get_contents(https://graph.facebook.com/me?access_token=) [function.file-get-contents]: failed to open stream: Result too large in C:\wamp\www\fbtest.php on line 30
但是,我怀疑这可能是WAMP的一个问题。所以我把这个代码直播的私人服务器上,并得到了这样的没有错误。但是,当我尝试点击登录 Facebook的按钮,它会打开一个新的窗口,它只是告诉我An error occurred. Please try again later.
我我不确定如何解决这个问题。