facebook-graph-api - 如何在 facebook iOS SDK 3.1 中发布到 friend 的墙?

标签 facebook-graph-api ios6 facebook-ios-sdk

我有适用于 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/

相关文章:

ios - 使用 MPMoviePlayerController 播放视频时如何静音/取消静音?

ios - FBSDKAppEvents.activateApp() 无法识别的选择器发送到实例

ruby-on-rails - 使用 Graph API 查明某个用户是否与另一个用户是好友

javascript - 对 JS SDK Facebook 事件的本质感到困惑

javascript - 我如何在 Meteor 中访问用户的 Facebook 好友列表?

ruby-on-rails - 如何使用 rails 在我的应用程序 facebook 页面上自动发布帖子

objective-c - 堆叠 presentViewController 后 statusBarFrame = 0

ios - 以编程方式创建的 UILabel 未出现在 IOS 7 Storyboard中

authentication - 如何在 iOS 6 中使用 openActiveSessionWithReadPermissions 在 SDK 3.1.1 上强制进行 webview 登录?

ios - iOS 中的 Facebook 登录 SDK 语言问题