我有适用于 iOS 6 的 SDK 3.1,用于发布状态更新,并且我有我想要在其墙上发布的人的 Facebook 用户 ID。
我只是想让它说“嗨”。到只有一个人的墙。 我可以使用“/[id]/feed”来定位他们的提要,但随后我必须提供一个图形对象?如果我无论如何使用 startForPostWithGraphPath() 。
最佳答案
我明白了!
首先当然要在此处实现 FBFriendPickerDelegate,除非您已经以某种方式获得了他们的好友 ID。 http://developers.facebook.com/docs/howtos/filter-devices-friend-selector-using-ios-sdk/
然后是重要的部分,如何发布到 friend 的墙:
- (void)facebookViewControllerDoneWasPressed:(id)sender
{
NSString* fid;
NSString* fbUserName;
// get facebook friend's ID from selection. just gets 1 right now.
for (id<FBGraphUser> user in friendPickerController.selection)
{
NSLog(@"\nuser=%@\n", user);
fid = user.id;
fbUserName = user.name;
}
//Make the post.
NSMutableDictionary* params = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"Join me!", @"message", @"http://itunes.apple.com/my-super-app", @"link", @"My Super App", @"name", nil];
NSLog(@"\nparams=%@\n", params);
//Post to friend's wall.
[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"%@/feed", fid] parameters:params HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{
//Tell the user that it worked.
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Shared"
message:[NSString stringWithFormat:@"Invited %@! error=%@", fbUserName, error]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
];
//Close the friend picker.
[self dismissModalViewControllerAnimated:YES];
}
关于facebook-graph-api - 如何在 facebook iOS SDK 3.1 中发布到 friend 的墙?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12850630/