我正试图在我的墙上发布消息,并希望在此帖子中一次标记多个用户。我尝试了FB page上的各种选项,但是无法做到。可能是我做得不对。感谢任何帮助,这就是我这样做的方式......
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"Test 2",@"message",
@"100004311843201,1039844409", @"to",
nil];
[self.appDelegate.facebook requestWithGraphPath:@"me/feed" andParams:params andHttpMethod:@"POST" andDelegate:self];
我也试过了message_tags
,但这似乎也不行。
答案 0 :(得分:4)
您需要使用Open Graph标记带有消息的人。 me / feed Graph API端点不支持此功能。
提到标记 https://developers.facebook.com/docs/technical-guides/opengraph/mention-tagging/
动作标记: https://developers.facebook.com/docs/technical-guides/opengraph/publish-action/
您可以查看最新的Facebook SDK for iOS附带的Scrumptious示例应用,了解如何执行此操作。
答案 1 :(得分:2)
要以ur fb状态标记朋友..您需要使用FBFriendPickerViewController和使用FBPlacePickerViewController的“place id”来获取朋友的“facebook id”。以下代码可以帮助您。
NSString *apiPath = nil;
apiPath = @"me/feed";
if(![self.selectedPlaceID isEqualToString:@""]) {
[params setObject:_selectedPlaceID forKey:@"place"];
}
NSString *tag = nil;
if(mSelectedFriends != nil){
for (NSDictionary *user in mSelectedFriends) {
tag = [[NSString alloc] initWithFormat:@"%@",[user objectForKey:@"id"] ];
[tags addObject:tag];
}
NSString *friendIdsSeparation=[tags componentsJoinedByString:@","];
NSString *friendIds = [[NSString alloc] initWithFormat:@"[%@]",friendIdsSeparation ];
[params setObject:friendIds forKey:@"tags"];
}
FBRequest *request = [[[FBRequest alloc] initWithSession:_fbSession graphPath:apiPath parameters:params HTTPMethod:@"POST"] autorelease];
[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
[SVProgressHUD dismiss];
if (error) {
NSLog(@"Error ===== %@",error.description);
if (_delegate != nil) {
[_delegate facebookConnectFail:error requestType:FBRequestTypePostOnWall];
}else{
NSLog(@"Error ===== %@",error.description);
}
}else{
if (_delegate != nil) {
[_delegate faceboookConnectSuccess:self requestType:FBRequestTypePostOnWall];
}
}
答案 2 :(得分:0)
如果您按照如何设置Open Graph for iOS的教程,如果您使用friendsPickerController,则可以执行以下操作:
// Create an action
id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
//Iterate over selected friends
if ([friendPickerController.selection count] > 0) {
NSMutableArray *temp = [NSMutableArray new];
for (id<FBGraphUser> user in self.friendPickerController.selection) {
NSLog(@"Friend selected: %@", user.name);
[temp addObject:[NSString stringWithFormat:@"%@", user.id]];
}
[action setTags:temp];
}
基本上,您可以在动作上的“tags”属性中设置朋友ID的数组