标签朋友在Facebook的照片上传 [英] Tag Friends in Facebook Photo Upload

查看:118
本文介绍了标签朋友在Facebook的照片上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要使用图形标记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?

谢谢!

EDIT 请参阅这里( https://developers.facebook.com/docs/reference/api/photo/#tags) ),看起来我需要总共发出三个电话:

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:


  1. 使用我已经拥有的代码发布照片

  2. 询问Facebook给我这张照片的ID(我可能从FBRequestDelegate获得)。

  1. Post the Photo with the code I already have
  2. Ask Facebook to give me the ID of this photo (which i can probably get from the FBRequestDelegate)
  3. Tag People after posting.



推荐答案

首先,您要上传图片。

        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)请求: *)请求didLoad:(id)result 方法将返回一个字典 result with 1 key id 。该ID是您刚刚上传的照片的照片ID,并保存为字符串:

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的照片上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆