我有以下代码,但FB.login给出了一个FB未定义的javascript错误.
我错过了什么?
<html>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function()
{
FB.init
({
appId : 'XXXX',
status : true,
cookie : true,
xfbml : true
});
};
(function()
{
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
FB.login(function(response)
{
if(response.session)
{
if(response.perms)
{
alert('yippee');
}
else
{
alert('oh no');
}
}
else
{
alert('login silly');
}
}, {perms:'email,user_birthday'});
</script>
hello
<fb:login-button></fb:login>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) facebook facebook-javascript-sdk facebook-login facebook-permissions
我正在尝试使用我根据新文档编写的以下代码来显示"发布到源"对话框(https://developers.facebook.com/docs/javascript/reference/FB.ui)但我得到了以下错误" ReferenceError:FB未定义 "
我使用的代码是最简单的我可以提出:
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxxxxx',
status : true,
xfbml : true
});
};
(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 = "http://connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
FB.ui({
method: 'feed',
name: 'Facebook Dialogs',
link: 'https://developers.facebook.com/docs/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.'
});
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
编辑1
如果我想在用户点击链接时打开对话框,我将使用jquery click事件
$(".userActions a.facebook").click(function() …Run Code Online (Sandbox Code Playgroud)