Saturday, 31 August 2013

iOS - Facebook: "(#100) Array does not resolve to a valid user ID";

iOS - Facebook: "(#100) Array does not resolve to a valid user ID";

In my app I post location, friends and photos to the user's wall. It works
just fine, except when I try to tag a friend and not upload a photo, then
I get the error:
Error ===== Error Domain=com.facebook.sdk Code=5 "The operation couldn't
be completed. (com.facebook.sdk error 5.)" UserInfo=0xa5e9620
{com.facebook.sdk:HTTPStatusCode=400,
com.facebook.sdk:ParsedJSONResponseKey={
body = {
error = {
code = 100;
message = "(#100) Array does not resolve to a valid user ID";
type = OAuthException;
};
};
code = 400;
}, com.facebook.sdk:ErrorSessionKey=<FBSession: 0x97a4b70, state:
FBSessionStateOpen, loginHandler: 0x97a4c00, appID: 534257903313640,
urlSchemeSuffix: , tokenCachingStrategy:<FBSessionTokenCachingStrategy:
0xa5e2ac0>, expirationDate: 2013-10-31 02:09:29 +0000, refreshDate:
2013-09-01 02:55:35 +0000, attemptedRefreshDate: 0001-12-30 00:00:00
+0000, permissions:(
"video_upload",
"basic_info",
"publish_stream",
installed,
"status_update",
"user_friends",
"create_note",
"share_item",
"photo_upload",
"publish_actions"
)>}
I have no problem tagging a friend when I also upload a photo, and I have
no problem posting just a place to the wall also.
Here's my code:
- (IBAction)post2:(id)sender {
if ([FBSession.activeSession.permissions
indexOfObject:@"publish_actions"] == NSNotFound) {
// No permissions found in session, ask for it
NSArray *permissions = [[NSArray alloc]
initWithObjects:@"publish_actions", @"upload_photos", nil];
[FBSession.activeSession requestNewPublishPermissions:permissions
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error) {
if (!error) {
[self post2:sender];
return;
// If permissions granted, publish the story
}
}];
}
else {
NSString *apiPath = nil;
NSMutableDictionary *params = [NSMutableDictionary
dictionaryWithObjectsAndKeys:@"oi", @"message", nil];
NSMutableArray *tags = [[NSMutableArray alloc] init];
if (self.foodPicture)apiPath = @"me/photos";
else apiPath= @"me/feed";
if(self.selectedPlace.id) {
[params setObject:self.selectedPlace.id forKey:@"place"];
}
NSString *tag = nil;
if(self.selectedFriends != nil) {
for (NSDictionary *user in self.selectedFriends) {
tag = [[NSString alloc]
initWithFormat:@"{\"tag_uid\":\"%@\"}",[user
objectForKey:@"id"] ];
[tags addObject:tag];
}
NSString *friendIdsSeparation=[tags
componentsJoinedByString:@","];
NSString *friendIds = [[NSString alloc]
initWithFormat:@"[%@]",friendIdsSeparation ]; [params
setObject:friendIds forKey:@"tags"];
}
if (self.foodPicture) {
[params setObject:self.foodPicture forKey:@"picture"];
}
FBRequest *request = [[FBRequest alloc] initWithSession:[FBSession
activeSession] graphPath:apiPath parameters:params
HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBRequestConnection *connection,
id result, NSError *error) {
if (error) {
NSLog(@"Error ===== %@",error.description);
}
else {
NSLog(@"eba!");
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Posted!" message:@"" delegate:self
cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
}];}
Thanks for the help

No comments:

Post a Comment