[英]Tag Friends in Facebook Photo Upload
我希望能夠使用圖表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];
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];
接下來,成功上傳后, - (void)request:(FBRequest *)request didLoad:(id)result
方法將返回具有1個key id
的字典result
。 該ID是您剛剛上傳的照片的photoID,您將其保存到字符串中:
NSString *photoID = [NSString stringWithFormat:@"%@", [(NSDictionary*)result valueForKey:@"id"]];
然后發出另一個GraphAPI請求以標記您的朋友。 在下面的代碼中,我正在標記一個特定的朋友,但是要標記多個朋友,請使用CSV字符串或數組:
[self.socialIntegration.facebook requestWithGraphPath:[NSString stringWithFormat:@"%@/tags/%@?access_token=%@", photoID, @"1381470076", self.socialIntegration.facebook.accessToken]
andParams:nil
andHttpMethod:@"POST" andDelegate:self];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.