0

I have a button "share on Facebook" in my website. When the user clicks on it, it opens a popup to share a picture on his profile. This works but I have a problem with the callback (I want to know if the user has shared something or just closed the popup without sharing anything).

I am trying to get the callback response in jquery. I have exactly the same problem as in this post: FB.ui feed not giving a callback. Unfortunately, the accepted answer just says to empty the cache, which did not work for me.

My code :

FB.ui(
{
    method: 'feed',
    name: 'Share a photo',
    link: url,
    picture: path,
},
function(response) 
{    
    if (response && response.post_id) 
    {
        window.console&&console.log('Post was published.');
    } 
    else 
    {
        window.console&&console.log('Post was not published.');
    }
});

Why is the response empty?

Community
  • 1
  • 1
rom
  • 3,592
  • 7
  • 41
  • 71

1 Answers1

2

You only get a Post ID after sharing if you authorize the user with the publish_actions permission. You will also have a hard time getting any callback without that permission, for a good reason: Usually people want to use it to do something that is not allowed anyway - rewarding users in some way for sharing or gating content:

Only incentivize a person to log into your app, enter a promotion on your app’s Page, or check-in at a place. Don’t incentivize other actions.

Source: https://developers.facebook.com/policy/

andyrandy
  • 72,880
  • 8
  • 113
  • 130
  • Are you sure I need `publish_actions`? On the page https://developers.facebook.com/docs/facebook-login/permissions#reference-publish_actions, they say ''Your app does not need to request the publish_actions permission in order to use the Feed Dialog, the Requests Dialog or the Send Dialog". – rom Feb 10 '16 at 20:27
  • Where should I put `publish_actions`? – rom Feb 10 '16 at 20:28
  • i did not say you need it for using the feed dialog. you only need it to get a post id. and you have to authorize users with the publish_actions scope. it´s a lot more complicated, you would have to go through a review process too. – andyrandy Feb 10 '16 at 20:33
  • from your comment above: "to be sure the user has shared a picture" - the question is: why do you want to be sure? what for exactly? that´s the most important question here. make sure you know the rules, see the last sentence of my answer. – andyrandy Feb 10 '16 at 20:34
  • If it's really complicated to get the post id, let's say I just want to know if the user has shared something: I have a form which the user cannot validate until he has shared something. Is it against the rules of Facebook? Do you have a link for that? – rom Feb 10 '16 at 20:39
  • well, that is exactly what i was talking about: it´s not allowed. users MUST share something ONLY because they really want to, you can´t force or reward them in any way. i will add the link to the platform policy in my answer. you MUST read all of it before creating any app. – andyrandy Feb 10 '16 at 21:19