如何使用SDK 3.5从iPhone应用程序进行状态更新



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

好了:通过下面的FBID并测试它。你也可以转发好友的FBID,以便在他们的留言板上发帖。要了解更多信息,请阅读- developers.facebook.com/docs For iOS。

 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
             }             
         }
     }];

希望能有所帮助。

获取访问令牌后才能发布状态。获得访问令牌后,使用以下代码发布状态

    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;
                }];
    }];

最新更新