【问题标题】:Post on friends wall using Facebook SDK 3.0 for iOS使用 iOS 版 Facebook SDK 3.0 在朋友墙上发帖
【发布时间】:2012-08-27 08:11:38
【问题描述】:

我想使用 facebook sdk 3.0 在我的朋友墙上发布消息。所以请任何人建议我。

我也试过this

但它对我不起作用

【问题讨论】:

    标签: iphone ios facebook


    【解决方案1】:

    我认为这段代码可能有效。

    NSMutableDictionary *params;
    params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   userID,  @"to",
                                   msg,@"message",
                                   theUrl, @"picture",
                                   appLink, @"link",
                                   nil];
    
    [facebook_ dialog:@"feed"
            andParams:params
          andDelegate:self];
    

    【讨论】:

    • facebook_ 在 FB sdk 3.0 中无法访问。我有这个 [FBRequestConnection startForPostStatusUpdate:message completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { [self showAlert:message result:result error:error]; self.buttonPostStatus.enabled = YES; }];
    【解决方案2】:

    https://developers.facebook.com/docs/howtos/feed-dialog-using-ios-sdk/

    您需要将已弃用的标头导入到您的项目中。它们位于 Documents/FacebookSDK/FacebookSDK.framework/Versions/A/DeprecatedHeaders。导入所有这些文件后,您可以创建一个 facebook 对象并执行其他答案所说的操作。 FB 3.0 SDK 不适用于任何使用 FBDialog 的旧功能(发送应用请求、发布到您的墙上等)。

    【讨论】:

      【解决方案3】:
      NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                             @"facebook key", @"app_id",
      
                                             @"http://developers.facebook.com/docs/reference/dialogs/", @"link",
                                             @"image link", @"picture",
                                             @" ", @"description",
                                             @"", @"name",
                                             @" ", @"caption",
                                             nil];
      
      
              [_facebook dialog:@"feed" andParams:params andDelegate:self];
      
              [_facebook logout];
      

      您无需进行 facebook 身份验证。如果您未登录,则首先显示登录屏幕,然后显示共享对话框。 Also refer

      【讨论】:

      • 它不适合我我正在使用新的 sdk。它没有 facebook 类。
      【解决方案4】:

      对于 Facebook SDK 3.0:

      我正在使用以下 FBRequestConnection 块在我的 facebook 朋友墙上分享我的应用程序,并使用给定的 facebookid 作为方法参数。如果您想在自己的墙上分享相同的内容,只需更改

      [NSString stringWithFormat:@"%@/feed",friendId]
      

      @"me/feed"
      
      -(void)postToFriendWall:(NSString*)friendId{
      
       NSString *pictureUrl = [NSString stringWithFormat:@"http://......."];
      
      
      NSMutableDictionary *postParams = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                        @"Name", @"name",
                                         @"www.mylink.com", @"link",
                                         @"Caption Text", @"caption",
                                         @"Description Text", @"description",
                                         @"Post Message", @"message",
                                         pictureUrl, @"picture",
                                         nil];
      
      [FBRequestConnection
       startWithGraphPath:[NSString stringWithFormat:@"%@/feed",friendId]
       parameters:postParams
       HTTPMethod:@"POST"
       completionHandler:^(FBRequestConnection *connection,
                           id result,
                           NSError *error) {
      
           if (!error) {
      
               UIAlertView *postSentAlert = [[UIAlertView alloc] initWithTitle:@"Facebook"
                                                                       message:NSLocalizedStringFromTable(@"kFacebookPostAlertTitle", @"ContactList", "")
                                                                      delegate:nil
                                                             cancelButtonTitle:NSLocalizedStringFromTable(@"kOK", @"ApplicationStrings", "")
                                                             otherButtonTitles:nil];
      
               [postSentAlert show];
      
           }
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-07-25
        • 1970-01-01
        相关资源
        最近更新 更多