Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't get the Facebook publish_action permission on iOS

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

like image 421
Darren Avatar asked Jul 03 '12 21:07

Darren


People also ask

How do I give an app permission on Facebook?

Tap in the top right of Facebook. Scroll down and tap Settings. Go to the Permissions section and tap Apps and Websites. Go to Apps, Websites and Games and tap Edit.

Does Facebook need Phone permission?

If you install the Facebook app on your Android, your phone or tablet should let you know that the app is asking for your permission to access information or use features from your Android. Almost all apps need certain permissions to run on Android, and we use these permissions to run features in the app.

What are Facebook permissions?

Permissions with Facebook Login. When a person logs into your app via Facebook Login you can access a subset of that person's data stored on Facebook. Permissions are how you ask someone if you can access that data. A person's privacy settings combined with what you ask for will determine what you can access.

Is the Facebook API free?

The Graph API is free to use, for all applicable use cases.


1 Answers

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!

like image 107
AlexanderN Avatar answered Sep 22 '22 07:09

AlexanderN