首先:我不是英国人,我的英语也不是很好,那么抱歉。 我的 FB 应用程序出现问题。
这是代码:
//My Script
<script src="http://connect.facebook.net/en_US/all.js"></script>
<p><a onload="postToFeed(); return false;"> </a></p>
<p id="msg"></p>
<script>
FB.init({appId: "********", status: true, cookie: true});
function postToFeed() {
// calling the API ...
var obj = {
method: "feed",
link: "http://apps.facebook.com/bachflower/",
picture: "http://glacial-hollows-5787.herokuapp.com/images/37p.png",
name: "Wild Rose - Rosa Canina",
caption: " ",
description: "Dona: Decisione, motivazione, accettazione con gioia del quotidiano. Chi ne ha bisogno tende a pensare: Non vale la pena… meglio rinunciare. Non serve a nulla… - App by medicinanaturale.pro"
};
function callback(response) {
}
FB.ui(obj, callback);
}
</script>
//This is my body OnLoad
<body text="#000000" onLoad="postToFeed();" >
问题是: 有些人可以在他们的墙上看到并正确分享 postToFeed 通知。 有些人看不到 postToFeed 的任何内容。 为什么?
有人可以帮助我吗?
比你, 安德里亚
最佳答案
postToFeed() 函数可能会在 FB 加载和初始化之前调用。 使用异步加载,如下所示:
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : 'YOUR_APP_ID', // App ID from the App Dashboard
channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File for x-domain communication
status : true, // check the login status upon init?
cookie : true, // set sessions cookies to allow your server to access the session?
xfbml : true // parse XFBML tags on this page?
});
postToFeed();
};
// Load the SDK's source Asynchronously
(function(d, debug){
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" + (debug ? "/debug" : "") + ".js";
ref.parentNode.insertBefore(js, ref);
}(document, /*debug*/ false));
</script>
请参见此处:http://developers.facebook.com/docs/reference/javascript/
关于javascript - Facebook 方法 : Feed - JavaScript - Body OnLoad,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13342750/