I'm trying to login to Facebook through my app using FBSDKLoginManager
. I'm asking for some permissions while logging. But every time i get the following error:
[11624:2243947] data----(null) [11624:2243947] Access Facebook page error:Error Domain=com.facebook.sdk.core Code=8 "The operation couldn't be completed. (com.facebook.sdk.core error 8.)" UserInfo=0x15eb2e80 {com.facebook.sdk:FBSDKErrorDeveloperMessageKey=Sorry, this feature isn't available right now: An error occurred while processing this request. Please try again later., com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCode=2, com.facebook.sdk:FBSDKGraphRequestErrorCategoryKey=0}
Could anyone please help? This is the code that I've written:
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithPublishPermissions:@[@"publish_actions"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
NSLog(@"data----%@",result.grantedPermissions);
if (error) {
// Process error
NSLog(@"Access Facebook page error:%@", error);
} else if (result.isCancelled) {
// Handle cancellations
} else {
// If you ask for multiple permissions at once, you
// should check if specific permissions missing
if ([result.grantedPermissions containsObject:@"publish_actions"]) {
// Do work
NSLog(@" publish actions permission granted");
[login logInWithReadPermissions:@[@"user_likes",@"user_birthday"] 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
if ([result.grantedPermissions containsObject:@"user_birthday"]) {
// Do work
NSLog(@"Permission 2: %@",result.grantedPermissions);
}
}
}];
}
}
}];
Login with Facebook SDK 4.x
Add following code to facebook login button click :
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions:@[@"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)
{
if (error)
{
// Error
}
else if (result.isCancelled)
{
// Cancelled
}
else
{
if ([result.grantedPermissions containsObject:@"email"])
{
[self getFBResult];
}
}
}];
Get Facebook Result Method :
-(void)getFBResult
{
if ([FBSDKAccessToken currentAccessToken])
{
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"id, name, first_name, last_name, picture.type(large), email"}]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error)
{
NSLog(@"fb user info : %@",result);
}
else
{
NSLog(@"error : %@",error);
}
}];
}
}
You can change the fields of permissions as you want.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.