问题描述
我想使用图形API来标记现有的朋友:
I'd like to be able to tag existing friends using the graph api:
这是我现在的代码。照片正在上传,但照片未标记user_id中指定的用户:
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];
message_tags
属性不是正确的属性要使用?
Is the message_tags
attribute not the correct attribute to use?
谢谢!
编辑
从我的请参阅这里(),看起来我总共打了三个电话:
EDITFrom what I see here (https://developers.facebook.com/docs/reference/api/photo/#tags), it looks like I need to make three calls in total:
- 代码我已经有
- 请Facebook给我这张照片的身份证(我可以从FBRequestDelegate获取)
- 标记发布后的人
推荐答案
好的,想出来。
以下是您的操作方法。
首先,您上传图片。
UIImage *testImage = [UIImage imageNamed:@"sendingTo"];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:kFacebookFBConnectAppID, @"app_id",
testImage, @"source",
@"TEST!", @"message", nil];
[self.socialIntegration.facebook requestWithGraphPath:[NSString stringWithFormat:@"/me/photos?access_token=%@", self.socialIntegration.facebook.accessToken]
andParams:params
andHttpMethod:@"POST" andDelegate:self];
接下来,成功上传后, - (void)请求:(FBRequest *)请求didLoad:(id)result
方法将返回一个字典结果
与1键 id
。该ID是您刚刚上传的照片的photoID,您将其保存到字符串中:
Next, upon successful upload, the - (void)request:(FBRequest *)request didLoad:(id)result
method will return a dictionary result
with 1 key id
. That ID is the photoID of the photo you just uploaded, which you save into a string:
NSString *photoID = [NSString stringWithFormat:@"%@", [(NSDictionary*)result valueForKey:@"id"]];
然后再创建一个GraphAPI请求来标记你的朋友。在下面的代码中,我标记了一个特定的朋友,但是为了标记多个朋友使用CSV字符串或数组:
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:
[self.socialIntegration.facebook requestWithGraphPath:[NSString stringWithFormat:@"%@/tags/%@?access_token=%@", photoID, @"1381470076", self.socialIntegration.facebook.accessToken]
andParams:nil
andHttpMethod:@"POST" andDelegate:self];
这篇关于标记Facebook中的朋友照片上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!