-4

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

4

2 回答 2

1

你去吧:在下面传递你的 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

             }             
         }
     }];

希望能帮助到你。

于 2013-06-01T08:18:57.103 回答
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;
                }];

    }];
于 2013-06-01T08:43:17.820 回答