简体   繁体   中英

Facebook error sharing facebook in ios

Printing description of error:
            Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed.  (com.facebook.sdk error 5.)" UserInfo=0x20918d40 {com.facebook.sdk:HTTPStatusCode=403, com.facebook.sdk:ParsedJSONResponseKey={
body =     {
    error =         {
        code = 200;
        message = "(#200) Permissions error";
        type = OAuthException;
    };
};
code = 403;
}, com.facebook.sdk:ErrorSessionKey=<FBSession: 0x1fd34770, state: FBSessionStateOpenTokenExtended, loginHandler: 0x1fde4440, appID: 463480747117294, urlSchemeSuffix: , tokenCachingStrategy:<FBSessionTokenCachingStrategy: 0x1fd7aeb0>, expirationDate: 2014-09-06 06:09:04 +0000, refreshDate: 2014-07-08 06:25:53 +0000, attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:(
installed,
"public_profile"
)>}

facebook error is coming when sharing image on facebook....

first check weather u hav set the permission "publish_actions","publish_stream" and so second check like below

   NSMutableDictionary *params = [[NSMutableDictionary alloc]initWithObjectsAndKeys:mytext, @"message",myImage, @"source",nil]; // set the formats
   if([FBSession.activeSession.permissions indexOfObject:@"publish_actions"] != NSNotFound) //checking weather the permission are requested or not
    {
        [FBRequestConnection startWithGraphPath:@"me/photos" parameters:params HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
        {
             //error checkings or success 

        }
    }

while opening the session u hav to set the permission's for example

 NSArray  *permissions = [[NSArray alloc] initWithObjects:@"publish_actions",@"publish_stream",nil]; //permissions

[FBSession openActiveSessionWithPermissions:permissions allowLoginUI:allowLoginUI completionHandler:^(FBSession *session,FBSessionState state,NSError *error)
        {
            [self sessionStateChanged:session state:state error:error];
            [FBSession setActiveSession:session];
        }];

hope this helps u :)

After banging my head for hours, I figured it out. It seems you need to go into your app Settings on developers.facebook.com, under "Status & Review", and request publish permissions for your app. If you only need to test it, you can get around by going to Roles and adding the Facebook user you're trying to login with as a developer for your app.

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.

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