【问题标题】:How to post to a friend's wall in facebook iOS SDK 3.1?如何在 facebook iOS SDK 3.1 中发布到朋友的墙上?
【发布时间】:2012-10-12 00:32:09
【问题描述】:

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

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

【问题讨论】:

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


    【解决方案1】:

    我想通了!

    当然首先在这里实现 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];
    }
    

    【讨论】:

    • 恭喜你搞定了——太糟糕了,这是一个很快就会被禁用的功能,请参阅developers.facebook.com/blog/post/2012/10/10/… 唯一能做到这一点的方法就是未来的 Feed 对话框。
    • 感谢您的信息。你知道如何显示针对朋友墙的提要对话框吗?
    • 当然,它就在文档中,developers.facebook.com/docs/reference/dialogs/feed - 关于参数的部分。
    • 但是当我没有名为 _facebook 的变量并且它不知道 Facebook 是什么类以及我是否尝试包含 facebook 时,如何访问新 sdk 中的 [_facebook dialog] 函数.h 我有很多错误?
    猜你喜欢
    • 2013-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多