Facebook iOS SDK 3.1 error message on the wall for friends

I am using the latest version of iOS for Android iOS 3.1.1 trying to post UIImage to my friends wall, I get error 5 (Error: HTTP status code: 403).

If I try to post an image on my wall, this works well, but not one of my friends.

My code: 1. before publishing, I check if the user has access rights when I do

-(void)postImageOnFriendsWall:(UIImage*)image FriendsArray:(NSArray*)friends { // if we don't have permission to announce, let first address that if ([FBSession.activeSession.permissions indexOfObject:@"publish_actions"] == NSNotFound) { [FBSession.activeSession reauthorizeWithPublishPermissions:[NSArray arrayWithObject:@"publish_actions"] defaultAudience:FBSessionDefaultAudienceFriends completionHandler:^(FBSession *session, NSError *error) { if (!error) { // re-call assuming we now have the permission [self postImageOnFriendsWall:image FriendsArray:friends]; } else { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alertView show]; } }]; } else { // can post image for (id<FBGraphUser> user in friends) { NSString *userID = user.id; NSLog(@"trying to post image of %@ wall",userID); NSMutableDictionary *postVariablesDictionary = [[NSMutableDictionary alloc] init]; [postVariablesDictionary setObject:UIImagePNGRepresentation(image) forKey:@"picture"]; [postVariablesDictionary setObject:@"my image" forKey:@"message"]; [FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"%@/photos",userID] parameters:postVariablesDictionary HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { if (error) { //showing an alert for failure UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Facebook" message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alertView show]; } else { //showing an alert for success UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Facebook" message:@"Shared the photo successfully" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alertView show]; } }]; } } } 

mention if i changed

startWithGraphPath:[NSString stringWithFormat:@"%@/photos",userID]

to

 startWithGraphPath:[NSString stringWithFormat:@"me/photos",userID] 

works fine.

what am I doing wrong? I tried to find the answers, but nothing helped. Thank!

0
post ios objective-c iphone facebook
Dec 11
source share
2 answers

This is due to insufficient permissions. As the FB document says:

Insfect_scope The request requires higher privileges than that provided by the access token. Resource Server SHOULD respond with an HTTP 403 (Forbidden) status code and MAY include a β€œscope” attribute with the scope required to access a protected resource.

You must obtain additional permissions to post to another user’s wall. The permission you need is @publish_stream, which "allows your application to publish content, comments, and preferences for user stream and user stream." This is a subset permission to publish, which also includes publishing. "(C)

Recent changes force you to divide the permissions required into two levels - basic , which allows you to read basic information about the user and advanced (message, etc.). Permission Lists Here: Advanced Permission List

This means that you must request the appropriate permissions in two steps. First get the basic one, and then ask for the advanced one.

+2
Dec 11
source share

You need to check your facebook app id, sometimes there is a problem with it. I have the same problem as on the wall of my friends wall, but change facebook Application id and it works perfectly.

0
Feb 05 '13 at 9:29
source share



All Articles