Reputation: 21
I try to post a photo to an album from an iOS app. I want users upload their photos to a fan page's specific album by their names, not page owner.
The problem is like the problem mentioned below:
Post a photo to an Album on a Facebook fan page without being the admin,
Post a photo to a page for iOS
Here are my code for post a photo
[params setObject:data forKey:@"source"];
FBRequest *request1 = [FBRequest requestWithGraphPath:@"v2.3/<album-id>/photos"
parameters:[NSDictionary dictionaryWithDictionary:params]
HTTPMethod:@"POST"];
And where I get the permissions
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
NSArray *permissions = [[NSArray alloc] initWithObjects:
@"publish_actions",
@"user_photos",
@"email",
@"user_likes",
@"publish_pages",
nil];
return [FBSession openActiveSessionWithPermissions:permissions
allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
switch (status) {
case FBSessionStateOpen:
break;
case FBSessionStateClosed:
break;
case FBSessionStateCreated:
break;
case FBSessionStateCreatedOpening:
break;
case FBSessionStateClosedLoginFailed:
break;
case FBSessionStateOpenTokenExtended:
break;
case FBSessionStateCreatedTokenLoaded:
break;
}
}];
}
When I start the request , I will get the error and it said:
code = 200
"error_user_msg" = You don't have permission to edit this photo or album.
"error_user_title" = "Insufficient permissions"
"is_transient" = 0
message = "Permissions error"
I've read documents and it looks like you just need publish_actions this permissions and albums-id then you can post on album.But I just got error.
When I change album-id to page-id it will work but photo will not belong any albums.
Did I miss something or I misunderstand the documents?
Upvotes: 2
Views: 13717
Reputation: 2553
Looks like you are running into an access token issue. In order to post to an album belonging to a page, you need to use the Page Access Token rather than the User Access Token: According to the documentation:
Page Access Token – These access tokens are similar to user access tokens, except that they provide permission to APIs that read, write or modify the data belonging to a Facebook Page. To obtain a page access token you need to start by obtaining a user access token and asking for the manage_pages permission. Once you have the user access token you then get the page access token via the Graph API.
You can find out about how to obtain Page Tokens from here.
Upvotes: 1