我修改了xdamman的优秀选择--共享器JQuery库(https://github.com/xdamman/selection-sharer),以使用FB.ui而不是facebook的/对话框/feed小部件。这是因为/对话框/feed小部件和/sharer/sharer.php小部件都无法控制共享链接的链接摘要。因此,我使用了以下代码:
FB.ui(
{
method: 'feed',
name: name, // (e.g. "Interesting News Item")
link: self.url2share, // (the current URL as determined by window.location.href, e.g. "https://www.commonspace.scot/articles/2688/poll-snp-support-surges-further-with-months-to-go-before-scottish-elections")
picture: picture, // (e.g. "https://www.commonspace.scot/public/artarticle/a3/41/4162_6493.jpg?c=64a2);%20?%3E")
caption: 'commonspace.scot',
description: text // (arbitrary text string)
},
function(response) {
if (response && response.post_id) {
//alert('Post was published.');
} else {
//alert('Post was not published.');
}
}
);FB.ui的初始化方式如下:
window.fbAsyncInit = function() {
FB.init({
appId : '1011782388842782',
xfbml : true,
version : 'v2.4'
});
};现在,真正的问题是--上面的代码在从的https://dev.commonspace.scot服务器上运行时,只运行了一个很好的,但是错误“发生了。请稍后再试。”每当在主服务器上共享时都会遇到。
我尝试过的事情:
作为FB.ui的参数。结果:“发生错误。请稍后再试。”
为该应用程序指定了下列重要设置:
..。共享程序库知道应用程序ID。
重要注意:这些错误是相当通用的,并且显示在很多Facebook中。到目前为止,我看到的大多数答案,包括堆栈溢出,都与SDK的其他部分有关,例如,对于这些特定的错误,OAuth特别常见。我不清楚,如果有的话,适用于这里的答案如何适用。我尝试过各种这样的解决方案,但不清楚的是,选择一个特定的“回调URI/URL”在这个上下文中意味着什么,或者它是否会有帮助。此问题仅与“共享者”对话框有关。
提前谢谢你。
发布于 2015-10-16 10:56:56
我很想知道是否有人能解释为什么FB.ui在开发站点上工作,而不是在生产站点上工作。这样的回答对其他人也是非常有用的。
同时,如果有其他人遇到了完全相同的问题,我最终回到使用/对话框/feed小部件而不是FB.ui,并做了以下更改:
var url = 'https://www.facebook.com/dialog/feed?' +
'app_id='+self.appId +
'&display=popup'+
'&picture='+encodeURIComponent(picture)+
'&caption='+document.domain+
'&name='+encodeURIComponent(name)+
'&description='+encodeURIComponent(text)+
'&link='+encodeURIComponent(self.url2share)+
'&href='+encodeURIComponent(self.url2share)+
'&redirect_uri='+encodeURIComponent(self.url2share);您可以使用“我的叉”https://github.com/djcf/selection-sharer查看完整的源代码,也可以自己使用库。
https://stackoverflow.com/questions/33167026
复制相似问题