Art*_*sev 5 cocoa-touch facebook objective-c facebook-graph-api ios
我希望能够使用图形api标记现有的朋友:
这是我目前的代码.照片正在上传,但照片未标记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];
Run Code Online (Sandbox Code Playgroud)
是message_tags属性不使用正确的属性?
谢谢!
编辑 从我在这里看到的(https://developers.facebook.com/docs/reference/api/photo/#tags),看起来我需要总共进行三次调用:
好吧,想通了.
这是你如何做到的.
首先,您上传图像.
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];
Run Code Online (Sandbox Code Playgroud)
接下来,成功上传后,该- (void)request:(FBRequest *)request didLoad:(id)result方法将返回result带有1个键的字典id.该ID是您刚上传的照片的photoID,您将其保存为字符串:
NSString *photoID = [NSString stringWithFormat:@"%@", [(NSDictionary*)result valueForKey:@"id"]];
Run Code Online (Sandbox Code Playgroud)
然后再制作另一个GraphAPI请求以标记您的朋友.在下面的代码中,我正在标记一个特定的朋友,但要标记多个朋友使用CSV字符串或数组:
[self.socialIntegration.facebook requestWithGraphPath:[NSString stringWithFormat:@"%@/tags/%@?access_token=%@", photoID, @"1381470076", self.socialIntegration.facebook.accessToken]
andParams:nil
andHttpMethod:@"POST" andDelegate:self];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3710 次 |
| 最近记录: |