Ruby facebook共享未给出回应
我知道有数百个与此相关的问题,大部分都有答案,但似乎没有一个适合我Ruby facebook共享未给出回应,ruby,facebook,ruby-on-rails-4,facebook-graph-api,fb.ui,Ruby,Facebook,Ruby On Rails 4,Facebook Graph Api,Fb.ui,我知道有数百个与此相关的问题,大部分都有答案,但似乎没有一个适合我 window.fbAsyncInit = function() { FB.init({ appId : #{FbAppId}, xfbml : true, version : 'v2.8' }); }; $(document).on('click', '#share_dialog_open',function(){ var imageur
window.fbAsyncInit = function() {
FB.init({
appId : #{FbAppId},
xfbml : true,
version : 'v2.8'
});
};
$(document).on('click', '#share_dialog_open',function(){
var imageurl = $(this).attr('image_url');
var blog_description = $(this).attr('descr');
var blog_title = $(this).attr('blog_title');
var blogid = $(this).attr('blogid');
var vb_id = $(this).attr('vb_id');
FB.ui({
method: 'feed',
link: "http://URL/" + vb_id,
picture: imageurl,
description: blog_description,
title: blog_title
}, function(response){
console.log(response);
alert(response);
if(response && !response == undefined){
window.location="/congrats"
}
});
});
在console.log中,我什么也没有得到,而在alert(response)中,我一直得到其中一个(未定义,[],[object])
任何形式的帮助都将不胜感激
我的Omniauth.rb中也有
provider :facebook, "#{FbAppId}", "#{FbAppSecret}", {:scope => 'email publish_actions email manage_pages publish_pages'}
对于每个人来说,他们在新API中遇到了同样的问题,最终不知何故来到这里寻找答案。下面是我如何解决它的
window.fbAsyncInit = function() {
FB.init({
appId : #{FbAppId},
xfbml : true,
version : 'v2.5' // don't_use_greater_version
});
};
FB.ui({
method: 'feed', // don't use share you won't get anything in response
link: "your_url_which_you_want_to_share,
picture: path_to_your_image,
description: your_description,
title: your_title
}, function(response){
console.log(response);
if (response == undefined || response == null) {
return
}
else if (response.length == 0 || !response.error_code) {
where_you_want_to_redirect
}
});
您在控制台中什么也得不到,但在下一行中使用相同对象的警报确实会输出一些东西……这是非常不可能的。更可能的情况是,您错过了打印到console的内容,因为您正在直接从页面重定向(一个警报将“暂停”,console.log不会)。因此,请删除该重定向,然后再次检查。@CBroe buddy如果我删除警报、控制台或不删除,则该重定向工作正常。主要问题是,我在单击弹出窗口上的“取消”按钮后,甚至在单击“共享”时,都没有得到响应。不允许使用共享选通。@WizKid你的意思是什么?如果你找到了一堆不同的答案,这并不重要。我是说这是不允许的。