I’d like to be able to tag existing friends using the graph api:
Here’s the code I have at the moment. The photo is being uploaded, but the photo isn’t tagging the user specified in the user_id:
UIImage *testImage = [UIImage imageNamed:@"sendingTo"];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:kFacebookFBConnectAppID, @"app_id",
testImage, @"source",
@"1381470076", @"message_tags",
@"TEST!", @"message", nil];
[self.socialIntegration.facebook requestWithGraphPath:[NSString stringWithFormat:@"/me/photos?access_token=%@", self.socialIntegration.facebook.accessToken]
andParams:params
andHttpMethod:@"POST" andDelegate:self];
Is the message_tags attribute not the correct attribute to use?
Thanks!
EDIT
From what I see here (https://developers.facebook.com/docs/reference/api/photo/#tags), it looks like I need to make three calls in total:
- Post the Photo with the code I already have
- Ask Facebook to give me the ID of this photo (which i can probably get from the FBRequestDelegate)
- Tag People after posting.
ok, figured it out.
Here’s how you do it.
First, you upload the image.
Next, upon successful upload, the
- (void)request:(FBRequest *)request didLoad:(id)resultmethod will return a dictionaryresultwith 1 keyid. That ID is the photoID of the photo you just uploaded, which you save into a string:Then make another GraphAPI request to tag your friends. In the code below I am tagging one specific friends, but to tag multiple friends use CSV string or array: