简体   繁体   English

iOS应用程序和发布到FaceBook

[英]iOS App and Posting to FaceBook

In my app, I would like to provide a facebook icon so my users can post to their wall. 在我的应用程序中,我想提供一个Facebook图标,以便我的用户可以发布到他们的墙上。 I have read ALOT about Facebook and the Facebook SDK, but I am hoping some Facebookers out there can give me some ideas on the best approach. 我已经阅读了关于Facebook和Facebook SDK的ALOT,但我希望一些Facebookers可以给我一些关于最佳方法的想法。

I have built a test app that logs in to facebook, but then I saw another app that brings me to the settings to configure facebook. 我已经构建了一个登录到Facebook的测试应用程序,但后来我看到另一个应用程序,它带我进入配置Facebook的设置。

SO, what is the best way to do this in an app? 那么,在应用程序中执行此操作的最佳方法是什么? Here are some questions: 以下是一些问题:

1) Should I provide the login from my app, or is it better to use the built in native settings? 1)我应该从我的应用程序提供登录,还是使用内置的本机设置更好? 2) If the settings are better, is there an example of how I bring up the dialog? 2)如果设置更好,是否有一个如何调出对话框的示例? Do I use SLComposeViewController? 我使用SLComposeViewController吗? 3) Do I ONLY need the Graph API? 3)我是否只需要Graph API?

I apologize if these questions are silly, but I have seen sooo many different ways, and many are pre 2012, so I do not want to do anything that is old. 如果这些问题很愚蠢我会道歉,但我看到很多不同的方式,很多都是2012年之前,所以我不想做任何旧的问题。 If I follow the Facebook docs, I do not see anything about the native iOS settings dialog. 如果我关注Facebook文档,我看不到有关本机iOS设置对话框的任何信息。

Any help is greatly appreciated!!!! 任何帮助是极大的赞赏!!!!

If all you are looking to achieve is post to the user's wall, I would recommend using the SLComposeViewController. 如果你想要实现的只是发布到用户的墙上,我建议使用SLComposeViewController。 This abstracts all the work in logging into Facebook and implementing the GraphAPI. 这抽象了登录Facebook和实现GraphAPI的所有工作。 A previous post answered this here: Tutorial for SLComposeViewController sharing 之前的帖子在这里回答了这个问题: SLComposeViewController共享教程

If you want more control over the Facebook integration, ie Read the User's Timeline, View/Change User Settings, etc. you will have to install the Facebook SDK and register your application with Facebook. 如果您想要更多地控制Facebook集成,即阅读用户的时间线,查看/更改用户设置等,您将必须安装Facebook SDK并在Facebook上注册您的应用程序。 This is more labor intensive, but the extra control and access to data may be what you need. 这需要更多的劳动力,但可以根据需要额外控制和访问数据。 The SDK can be access here as well as some demos and example code: https://developers.facebook.com/docs/ios 可以在这里访问SDK以及一些演示和示例代码: https//developers.facebook.com/docs/ios

If you are going to post only text or image than better way is using SLComposeViewController. 如果您要仅发布文本或图像,那么使用SLComposeViewController更好。 Why? 为什么? No need to register app on developer.facebook.com. 无需在developer.facebook.com上注册应用程序。 Native login, and easy to create post. 原生登录,轻松创建帖子。 Example to do it: 示例:

    SLComposeViewController *controllerSLC = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controllerSLC setInitialText:@"My post"];
[controllerSLC addURL:[NSURL URLWithString:@"http://www.example.com"]];
[controllerSLC addImage:[UIImage imageNamed:@"img.jpg"]];
[self presentViewController:controllerSLC animated:YES completion:nil];

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

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