gpt4 book ai didi

javascript - Facebook 提要对话框不起作用

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:04:22 25 4
gpt4 key购买 nike

我试图让 Facebook Feed 对话框在测试站点上工作,但我不断收到相同的错误消息:“[app_name] 发生错误。请稍后重试。”。当我查看 documentation我意识到文档中的示例也不起作用。

尝试了多种不同的解决方案。这是我的测试代码:

 <html xmlns:fb="https://www.facebook.com/2008/fbml">
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : '400714233333865', // App ID from the App Dashboard
channelUrl : '//demo.xxxxxxx.se/nptest/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?
});

// Additional initialization code such as adding Event Listeners goes here

};

function postToFeed(){

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.');
}
}
);

};

// Load the SDK's source 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>



<div id='fb-root'></div>
<a onClick="postToFeed('Text');">
Share in the feeeeeeeeeeeeed
</a>
</body>
</html>

有没有人遇到过类似的问题或解决方案?

最佳答案

确保您正在通过应用程序设置中指定的相同 URL 进行测试。在您的提要对话框中提供您自己的链接和图像,即在应用程序设置中指定的您自己域的链接,而不是 Facebook 示例中给出的链接。

关于javascript - Facebook 提要对话框不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13011697/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com