Can't get the Facebook publish_action permission on iOS

16,085

Check if you have done the steps below:

https://developers.facebook.com/docs/opengraph/tutorial/

"Note: The user-prompt for this permission will be displayed in the first screen of the Enhanced Auth Dialog and cannot be revoked as part of the authentication flow." - link

Try this if you havent already:

Auth Dialog -> Configure how Facebook refers users to your app - > Add publish_actions permissions.

https://developers.facebook.com/docs/opengraph/authentication/

"To enable the new Auth Dialog, go to the App Dashboard, and enable the Enhanced Auth Dialog setting in the Advanced section of your app." -link

Hope this helps!

Share:
16,085
Darren
Author by

Darren

Updated on June 09, 2022

Comments

  • Darren
    Darren almost 2 years

    I've spent hours on this and can't get it to work. Basically I just want a button in my app that will 'Like' itself on Facebook. I've created the app on dev Facebook and have an associated App Page. In my code I request these permissions:

    _permissions =  [NSArray arrayWithObjects:@"publish_stream", @"publish_actions", @"user_birthday", nil];
    

    I can retrieve a profile picture fine, but when I try to 'Like' using this code:

    NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                           _facebook.accessToken, @"access_token",
                                           nil];
            [_facebook requestWithGraphPath:@"329756493773381/og.likes" andParams:params andHttpMethod:@"POST" andDelegate:self];
    

    I get this error response:

    (facebookErrDomain error 10000.)" UserInfo=0x20090590 {error={
        code = 200;
        message = "(#200) Requires extended permission: publish_actions";
        type = OAuthException;
    }}
    

    When logging in on the app, Facebook asks me for permission to see my birthday, and tell's me it will Post on my behalf but it seems to not get the publish_actions permission.

    Is there something i'm missing that I need to do?

    I see Temple Run has a Facebook Like button and offers bonus coins for pressing it. This is what I wish to achieve.

    EDIT -------

    I've changed my permissions to just @"publish_actions", @"user_birthday" and now the auth dialogue says

    "This app may post on your behalf, including objects you liked and more"

    which seems to be the publish_actions permission, however I was still getting the error

    message = "(#200) Requires extended permission: publish_actions";

    I've changed this line:

    [_facebook requestWithGraphPath:@"329756493773381/og.likes" andParams:params andHttpMethod:@"POST" andDelegate:selrf];
    

    to this:

    [_facebook requestWithGraphPath:@"329756493773381/og.likes" andDelegate:self];
    

    and I do now get a response back, although it doesn't post a 'like'

    This is the result response:

    {
        data =     (
        );
        paging =     {
            next = "https://graph.facebook.com/329756493773381/og.likes?sdk=ios&sdk_version=2&access_token=BAAGeAp3ZBGwoBAPICjlgB5zK0YECyP8yElf8hJoMrx8Qs4vjeZAK5PlXFAVbGM1JyXHE0wZBvU0aBeCzCUTZBejQgoJ44CAIQsrG64TfrHdxjMqWD&format=json&offset=25&limit=25";
        };
    }
    

    Any idea what to try next?

    EDIT 2 --------------- I'm making progress with this. I've added the users id to the graph request like this

    NSString *graphPath = [NSString stringWithFormat:@"%@/og.likes",facebookID];
    

    and used these parameters

    NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                           @"AAAGeAp3ZBGwoBABvKjsPZAoQQNG9cDPJI2v2TI8acyyPSNtm9ZBkfydHqVZAjSKWSbLuvFwxyxSrCts7kFZCnh7Y6f5PFNlWb6smF8XF33wlRZBgfLyhT1", @"access_token",
                                           @"http://samples.ogp.me/329756493773381", @"object",
                                           nil];
    

    and now I get a like showing up on my timeline :-) I was using the access-token supplied by the Facebook login, but it seems the one supplied by the graph object is different.

    Now, the like that i'm seeing has this pattern:

    Darren likes object on MyAPP

    Is it even possible to have it as

    Darren likes MyAPP with it linking to the app Facebook page?

    Thanks