I know there are hundreds of questions related to this and mostly with answers but none of them seems to work with me.
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"
}
});
});
In console.log i'm getting nothing and in alert(response) I keep getting either one these (undefined, [], [object Object])
Any kind of help of would be appreciated.
And I have also in my Omniauth.rb
provider :facebook, "#{FbAppId}", "#{FbAppSecret}", {:scope => 'email publish_actions email manage_pages publish_pages'}
To everyone, who got the same problem with new API and eventually somehow came here in search for answer. Here is how I solved it.
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
}
});