我知道有数百个与此相关的问题,主要是答案,但似乎没有一个与我合作。
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中,我什么也没得到,并且处于警报状态(响应)我一直得到这些(undefined,[],[object Object])
任何形式的帮助都将不胜感激。
我也在我的Omniauth.rb
provider :facebook, "#{FbAppId}", "#{FbAppSecret}", {:scope => 'email publish_actions email manage_pages publish_pages'}
答案 0 :(得分:1)
对于每个人来说,他们遇到了与新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
}
});