2

我有适用于 iOS 6 的 SDK 3.1 用于发布状态更新,并且我有我想在他们的墙上发布的人的 facebook 用户 ID。

我只是想让它说“嗨”。只有一个人的墙。我可以使用“/[id]/feed”来定位他们的提要,但是我必须提供一个图形对象?如果我仍然使用 startForPostWithGraphPath() 。

4

1 回答 1

4

我想到了!

首先当然在这里实现 FBFriendPickerDelegate ,除非您已经以某种方式获得了他们的朋友 ID。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];
}
于 2012-10-15T19:19:44.777 回答