gpt4 book ai didi

javascript - 使用 FB.ui 共享 Facebook 页面

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

我正在我们的网站上实现共享功能。我按照 https://developers.facebook.com/docs/javascript/quickstart/v2.4 上的文档进行操作

我们的代码如下:

var link_url = 'http://example.com/some/link';         // Works fine
link_url = 'https://www.facebook.com/<our_fan_page>'; // DOES NOT WORK

$("#btnShare").click(function(event){
FB.ui({
method: 'share',
href: link_url,
}, function(response){
if(response && response.post_id){
alert("Thanks for sharing");
}else{
alert("Oop!");
}
});
});

对于像 http://example.com/some/link 这样的链接,它工作正常

问题是:对于我们的 FB 页面链接(例如 https://www.facebook.com/[our_page_name]),它不起作用

当点击“分享”按钮时,FB 会正常显示一个对话框。但是当我尝试点击“发布到 Facebook”按钮时,它显示错误

Sorry, this feature isn't available right now: An error occurred while processing this request. Please try again later.

有人遇到同样的问题吗?以及如何解决?

最佳答案

它已经成为一个旧帖子,但我在寻找修复程序时看到了它,因此这个问题的解决方案仍然可以使我们中的一些人受益

这是我使用的 JS 代码:

function fbs_click(width, height) {
var leftPosition, topPosition;
//Set borders.
leftPosition = (window.screen.width / 2) - ((width / 2) + 10);
//Set title and status bars.
topPosition = (window.screen.height / 2) - ((height / 2) + 50);
var windowFeatures = "status=no,height=" + height + ",width=" + width + ",resizable=yes,left=" + leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY=" + topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no";
u=location.href;
t=document.title;
window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer', windowFeatures);
return false;
}

这是 HTML 代码:

<a href="http://www.facebook.com/share.php?u=YOURLINK" onClick="return fbs_click(500, 300)" target="_blank" title="Share This on Facebook">

如您所见,我没有使用 FB.ui(),但这个技巧可以解决问题。

为避免出现该问题:

Sorry, this feature isn't available right now: An error occurred while processing this request. Please try again later.

确保您要共享的链接不是本地主机链接(这是我收到该错误的唯一原因)。

关于javascript - 使用 FB.ui 共享 Facebook 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31332029/

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