1、注册成为开发者:https://developers.facebook.com/
2、下载FacebookSDK安装包,默认安装路径为:~/Documents/FacebookSDK
3、导入FBSDKCoreKit.framework和FBSDKLoginKit.framework
4、点击gettingstarted,进行plist和 URLSchemes配置,以及AppDelegate.m中的配置
5、在登录界面导入
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
6、获取token FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions:@[@"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
// Process error
} else if (result.isCancelled) {
// Handle cancellations
} else {
// If you ask for multiple permissions at once, you
// should check if specific permissions missing
NSLog(@"token = %@",result.token.tokenString);
if (result.token.tokenString!=nil) {
[self loginWithFaceBookToken:result.token.tokenString];
}
if ([result.grantedPermissions containsObject:@"email"]) {
// Do work
}
}
}];