要成为facebook开发者首先你得是facebook用户,也就是说你得有一个facebook账号,没有的赶紧注册,全中文,注册步骤超简单,如果不会翻墙,不会注册的可以看这篇文章http://blog.csdn.net/huangxuan518/article/details/52688067
注册好后facebook账号,打开facebook开发者页面https://developers.facebook.com/,如果你已经登录facebook网站,则页面上面会出现注册按钮,如果没有登录,则会出现登录按钮,点击登录或者注册按钮
输入用户名、密码,点击登录,然后点击注册,这个注册是用facebook账号注册为开发者账号,一个账号,实际上就是多了一个开发者的身份和权限
点一下开关按钮,切换到是,表示你同意注册开发者账号,然后点注册
注册成功,点击完成。完成后会自动跳到如下界面
选择你是需要在什么端开发,苹果、安卓还是其他,我是苹果,所以选择iOS
选择一个已经存在的应用,如果没有会出现新建facebook应用编号按钮
点击后出现如下界面
选择类别后,点击创建应用编号
按照提示进行安全验证后点击提交,至此我们的应用就创建好了,然后会跳转到如何集成界面,我们按照步骤一步步来集成。
首先下载SDK
解压并打开,把文件夹中的FBSDKCoreKit.Framework, FBSDKLoginKit.Framework, FBSDKShareKit.Framework还有Bolts.framework,官网少了这个,拖拽到你的工程(注意红色的框架很重要,官网的文档少添加了这个框架,所以各种报错,我按照官网教程操作,也折腾了一天时间,后来用pod集成好的,如果你怕麻烦可以直接pod集成,超简单)
#import <FBSDKCoreKit/FBSDKCoreKit.h>
- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBSDKAppEvents activateApp];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
return YES;
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
#import <FBSDKLoginKit/FBSDKLoginKit.h>
FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
loginButton.center = self.view.center;
[self.view addSubview:loginButton];
#import <FBSDKCoreKit/FBSDKCoreKit.h>
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}