我正在尝试编写可以创建群组的Facebook应用,但它无法正常工作。我的最小完整示例,您可以在here(我无法让Facebook API在jsFiddle上工作)戳,如下所示:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Create Group</title>
</head>
<body>
<script>
window.fbAsyncInit = function() {
FB.init({
appId: '784633881599418',
xfbml: true,
version: 'v2.2'
});
document.getElementById('create').addEventListener('click',
function() {
FB.login(function() {
FB.ui({
method: 'game_group_create',
name: 'Test Group',
description: 'This is a test. Only a test.',
privacy: 'CLOSED'
}, function(response) {
if (response && response.id) {
alert('Success: ' + response.id);
} else {
alert('Error.');
}
});
});
}, false);
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {
return;
}
js = d.createElement(s);
js.id = id;
js.src = "//connect.facebook.net/en_US/sdk/debug.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<button id="create">Create Group</button>
</body>
</html>
当用户点击该按钮时,系统会提示他们登录(如果他们还没有)并授权该应用(如果他们还没有),就像您一样。期待。但在那之后,一个Facebook框出现在窗口中间,带有一个永久的加载指示器。同时,控制台会记录以下错误:
GET https://www.facebook.com/login.php?skip_api_login=1&api_key=784633881599418…4d12677ce003e1ddf.googledrive.com%252Ff13eb6ab9%26relation%3Dparent.parent 500 (Internal Server Error)
Refused to display 'https://www.facebook.com/login.php?skip_api_login=1&api_key=784633881599418…4d12677ce003e1ddf.googledrive.com%252Ff13eb6ab9%26relation%3Dparent.parent' in a frame because it set 'X-Frame-Options' to 'DENY'.
发生了什么,我该如何解决?
答案 0 :(得分:0)
所以我评论了FB.login(function() {
和相应的});
并修复了它。