ステータスの更新を投稿するために iOS 6 で動作する SDK 3.1 があり、ウォールに投稿したい人の Facebook ユーザー ID があります。
「こんにちわ」と言いたいだけです。たった一人の壁に。「/[id]/feed」でフィードをターゲットにできますが、グラフ オブジェクトを提供する必要がありますか? とにかく startForPostWithGraphPath() を使用する場合。
ステータスの更新を投稿するために iOS 6 で動作する SDK 3.1 があり、ウォールに投稿したい人の Facebook ユーザー ID があります。
「こんにちわ」と言いたいだけです。たった一人の壁に。「/[id]/feed」でフィードをターゲットにできますが、グラフ オブジェクトを提供する必要がありますか? とにかく startForPostWithGraphPath() を使用する場合。
私はそれを考え出した!
何らかの方法でフレンド ID を既に持っていない限り、まずここで FBFriendPickerDelegate を実装します。http://developers.facebook.com/docs/howtos/filter-devices-friend-selector-using-ios-sdk/
次に重要な部分、友達のウォールに投稿する方法:
- (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];
}