是的,您可以使用 Javascript SDK 发布到墙上...这使用 jQuery 来检测对作为共享按钮的 id 的点击,因此请确保在任何 facebook javascript 之前添加它:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
如果您还没有加载 FB Javascript SDK,您还需要加载:
<script>
window.fbAsyncInit = function () {
FB.init({
appId: 'INSERT APP ID',
status: true, // check login status
cookie: true, // enable cookies to allow the server to access the session
oauth: true // enable OAuth 2.0
});
};
// Load the SDK Asynchronously
(function (d) {
var js, id = 'facebook-jssdk',
ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {
return;
}
js = d.createElement('script');
js.id = id;
js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>
然后添加以下代码:
$("#shareclick").click(function () {
FB.ui({
method: 'feed',
name: 'The Post Title',
caption: 'skruffymedia testing caption post',
description: (
'Testing the description of the skruffymedia app post!'),
link: 'http://www.skruffymedia.com',
picture: 'http://www.skruffymedia.com/facebook.jpg'
}, function (response) {
if (response && response.post_id) {
alert('posted');
} else {
alert('not shared');
}
});
}); //End Share Click
我将在我的博客http://www.skruffymedia.com/blog/creating-a-facebook-like-gate-competition/的下一步中包含这个答案