1

I am trying to get access to Facebook to post images to a page from an iOS app. But so far I can't even get it to give me the permissions I need.

I've done a lot of searching including iOS 6 Facebook posting procedure ends up with "remote_app_id does not match stored id" error and Facebook Graph Api Fan page photo upload (IOS) but nothing in those or other posts is solving this issue.

Here is the auth bit of the code:

ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];

NSDictionary *options = @{
                          ACFacebookAppIdKey: @"xxxxxxxxxxxxxx",
                         ACFacebookPermissionsKey: @[@"manage_pages"],
                          ACFacebookAudienceKey: ACFacebookAudienceEveryone
                          };

[accountStore requestAccessToAccountsWithType:accountType options:options completion:^(BOOL granted, NSError *error)
 {
     if (granted)
     {
         NSDictionary *options = @{
                                   ACFacebookAppIdKey: @"xxxxxxxxxxxxxx",
                                   ACFacebookPermissionsKey: @[@"photo_upload"],
                                   ACFacebookAudienceKey: ACFacebookAudienceEveryone
                                   };

         [accountStore requestAccessToAccountsWithType:accountType options:options completion:^(BOOL granted, NSError *error)
          {
              if (granted)
              {
                   // then do the upload - but it never gets here
              }
              else
              {
                   // handle error - this is where it ends up
              }
          }];
     }
     else
     {
          // handle error
     }
 }];

As suggested on some of the other posts on this I am requesting the read permissions first before the write ones. It gets the manage_pages permission fine.

When I ask for the photo_upload permission the Facebook permissions alert pops up asking me to confirm that it can post on my behalf and I click OK - but that permission request block returns with granted set to FALSE.

The full error message I am getting at that point is "The Facebook server could not fulfill this access request: Invalid permission: photo_upload"

On the Facebook App site I think I have done everything I need to do: I have created my App and got an AppId, added iOS as a platform and set the BundleId to the same one the iOS app is using, and on the advanced tab set it to be a Native app.

Has anyone got any ideas what I am doing wrong?

Community
  • 1
  • 1
Simon East
  • 2,516
  • 2
  • 18
  • 21

1 Answers1

0

Use publish_actions as your permission. The new Facebook API suggests using publish_actions in place of publish_stream when applicable. publish_stream should be included when you want to add the following capabilities posting to a friend’s feed, posting questions, creating notes, and posting content to events or groups.

urnotsam
  • 770
  • 7
  • 24
  • I tried changing "photo_upload" to "publish_stream" and I get the same issue but now with the error "Invalid permisson: publish_stream" – Simon East Aug 05 '14 at 15:21
  • `publish_stream` may not work for what you are doing. It may be worth trying `publish_action`. Not sure if that will fix your issue, but it seems like your issue is coming from the permission so it would be worth looking into `publish_action`. Heres a discussion about this topic http://stackoverflow.com/questions/7590878/permission-migration-from-publish-stream-to-publish-action – urnotsam Aug 05 '14 at 15:30
  • OK so yes this was the issue - it looks like there is no publish_stream permisson now either - the permission is called "publish_actions". And it does seem you can combine the call to get manage_pages and publish_actions in one permissions call so I don't think the stuff about needing to ask for read and then write permissions seems to apply any more either. Rather than confuse people to you want to add another answer but saying "publish_actions" and then I'll accept that. – Simon East Aug 05 '14 at 16:01
  • @SimonEast I have updated my answer to suggest when to use publish_stream instead of publish_action – urnotsam Aug 05 '14 at 16:49
  • I've accepted it - but I think the permission publish_actions has an s on the end of it – Simon East Aug 05 '14 at 21:02