fb.ui 関数を正常にロードして実行する方法がわかりません。Facebook アプリ ID が必要であることがわかったので、空白のアプリを作成して appId セクションに配置しました。これは私の現在のコードです:
ロードして初期化します。
<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 {} を関数で囲みますか?