0
我無法弄清楚如何成功加載和執行fb.ui函數。我看到你需要有一個Facebook應用程序ID,所以我創建了一個空白的應用程序,並把它放在appId部分。這是我當前的代碼:使用fb.ui創建共享彈出框
加載和初始化:
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '1404387053111932',
channelUrl : 'channel.htm;',
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 = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
FB.ui腳本:
<script>
FB.ui(
{
method: 'feed',
name: 'The Facebook SDK for Javascript',
caption: 'Bringing Facebook to the desktop and mobile web',
description: (
'A small JavaScript library that allows you to harness ' +
'the power of Facebook, bringing the user\'s identity, ' +
'social graph and distribution power to your site.'
),
link: 'https://developers.facebook.com/docs/reference/javascript/',
picture: 'http://www.fbrell.com/public/f8.jpg'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
</script>
channel.html文件:
<html>
<head>
<script src="http://connect.facebook.net/en_US/all.js"></script>
</head>
<body>
</body>
</html>
我想我的主要問題我如何調用這段代碼來執行點擊操作?我是否會圍繞fb.ui {}包裝一個函數?