简体   繁体   English

使用facebook 3.1 SDK在ios app上在facebook上发布状态

[英]posting status on facebook from ios app using facebook 3.1 SDK

I am working for an iOS app and I want to integrate Facebook sdk 3.1 for posting status on facebook but I really dont have any idea how to do it. 我正在为一个iOS应用程序工作,我想整合Facebook sdk 3.1在Facebook上发布状态,但我真的不知道如何做到这一点。 Can anybody please provide me link to easy tutorials or step by step approach for how to do it. 任何人都可以提供链接到简单的教程或逐步的方法,如何做到这一点。

To set up your Xcode project, read the instructions on the Facebook developer site . 要设置Xcode项目,请阅读Facebook开发人员站点上的说明。

You can create / open a session using [FBSession openActiveSessionWithAllowLoginUI:YES]; 您可以使用[FBSession openActiveSessionWithAllowLoginUI:YES];创建/打开会话[FBSession openActiveSessionWithAllowLoginUI:YES];

To publish to your timeline, you'll need to authorise with write permissions: 要发布到您的时间轴,您需要使用写入权限进行授权:

[[FBSession activeSession] reauthorizeWithPublishPermissions:@[ @"publish_stream" ] defaultAudience:FBSessionDefaultAudienceEveryone completionHandler:^(FBSession *authSession, NSError *authError) {

    // If auth was successful, create a status update FBRequest
    if (!authError) {
        FBRequest *postRequest = [FBRequest requestForPostStatusUpdate:@"Hello, world!"];

        [postRequest startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {

             // TODO: Check for success / failure here

         }];
    }

}];

Try this: 尝试这个:

 [FBRequestConnection startForPostStatusUpdate:@"I've been through the storm, future, present and past.. Light as a feather, swift as a cat.. Clickety clack, clickety clack!!" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
        NSLog(@"posted");
    }];

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM