如何使用SDK 3.5从iPhone App进行状态更新?

时间:2013-06-01 07:51:43

标签: iphone ios facebook

我已将facebook SDK 3.5与我的iPhone应用程序集成。授权,登录工作完全正常,但我无法弄清楚如何进行状态更新。一些代码会有所帮助。 谢谢!

2 个答案:

答案 0 :(得分:1)

你去:在下面传递你的FBID并测试它..你也可以传递你朋友的FBID,以便发布在他们的墙上..欲了解更多信息,请阅读 - developers.facebook.com/docs for iOS。< / p>

 NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   YourFBID,@"to",
                                   nil];

    [FBWebDialogs presentFeedDialogModallyWithSession:[FBSession activeSession]
                                           parameters:params
                                              handler:
     ^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
         if (error) {
             // Error launching the dialog or publishing a story.
             NSLog(@"Error publishing story.");
         } else {
             // Success here

             }             
         }
     }];

希望它有所帮助。

答案 1 :(得分:1)

您只有在获得访问令牌后才能发布状态。获得访问令牌后,请使用以下代码发布状态

    NSString *name = self.loggedInUser.first_name;
NSString *message = [NSString stringWithFormat:@"Hello Friends i am %@ i created this app on Date %@ using facebook SDK.",name,[NSDate date]];

// if it is available to us, we will post using the native dialog
BOOL displayedNativeDialog = [FBNativeDialogs presentShareDialogModallyFrom:self
                                                                initialText:nil
                                                                      image:nil
                                                                        url:nil
                                                                    handler:nil];
if (!displayedNativeDialog) {

    [self performPublishAction:^{
        // otherwise fall back on a request for permissions and a direct post
    [FBRequestConnection startForPostStatusUpdate:message
    completionHandler:^(FBRequestConnection *connection, id result, NSError *error) 
                {
                   [self showAlert:message result:result error:error];
                   self.buttonPostStatus.enabled = YES;
                }];

    }];