iphone - Error when post score using social frame work Ios -


this method send new score:

-(void)sendscore :(int) score : (nsstring *)uid : (acaccount *)ac{     nsstring *url =[nsstring stringwithformat:@"https://graph.facebook.com/%@/scores",uid];     nsurl * strurl =[nsurl urlwithstring:url];     nsdictionary * parameter =@{@"score": @"10000"};     slrequest * request =[slrequest requestforservicetype:slservicetypefacebook                                             requestmethod:slrequestmethodpost url:strurl parameters:parameter];     request.account = _accfb;     [request performrequestwithhandler:^(nsdata *responsedata, nshttpurlresponse *urlresponse, nserror *error) {         if (!error) {             nslog(@"error: %@",error);             nsstring * str = [[nsstring alloc]initwithdata:responsedata encoding:nsutf8stringencoding];             nslog(@"str: %@",str);         }      }]; } 

when run , show error:

{
    "message":"(#200) requires extended permission: publish_actions",
    "type":"oauthexception",
    "code":200
}

how can add publish_actions ?

you can request additional permissions active session @ time. facebook recommends ask permissions when app needs them complete action initiated user. note cannot add read , write permissions together.

here's code request publish_actions publish permissions active session-

fb ios sdk

[fbsession.activesession requestnewpublishpermissions:[nsarray arraywithobject:@"publish_actions"]                                   defaultaudience:fbsessiondefaultaudiencefriends                                 completionhandler:^(fbsession *session, nserror *error) {                                   __block nsstring *alerttext;                                   __block nsstring *alerttitle;                                   if (!error) {                                     if ([fbsession.activesession.permissions                                           indexofobject:@"publish_actions"] == nsnotfound){                                       // permission not granted, tell user not publish                                       alerttitle = @"permission not granted";                                       alerttext = @"your action not published facebook.";                                       [[[uialertview alloc] initwithtitle:title                                                       message:text                                                      delegate:self                                             cancelbuttontitle:@"ok!"                                             otherbuttontitles:nil] show];                                     } else {                                       // permission granted, publish og story                                       [self publishstory];                                     }                                    } else {                                     // there error, handle                                     // see https://developers.facebook.com/docs/ios/errors/                                   }                                 }]; 

social framework

-(void)requestpermissions {     acaccountstore *accountstore = [[acaccountstore alloc] init];     __block acaccount *facebookaccount = nil;      acaccounttype *facebookaccounttype = [accountstore accounttypewithaccounttypeidentifier:acaccounttypeidentifierfacebook];      // specify app id , permissions     nsdictionary *options = @{                     acfacebookappidkey: @"myappid",                     // read permissions here (if any)                     acfacebookpermissionskey: @[@"email"],                     acfacebookaudiencekey: acfacebookaudiencefriends    };     [accountstore requestaccesstoaccountswithtype:facebookaccounttype                                        options:options completion:^(bool granted, nserror *e)    {      if (granted) {           nsdictionary *options2 = @{                           acfacebookappidkey: @"myappid",                           // publish permissions here                           acfacebookpermissionskey: @[@"publish_actions"],                           acfacebookaudiencekey: acfacebookaudiencefriends          };          [accountstore requestaccesstoaccountswithtype:facebookaccounttype options:options2 completion:^(bool granted, nserror *error) {              if (granted) {                  nsarray *accounts = [accountstore accountswithaccounttype:facebookaccounttype];                   facebookaccount = [accounts lastobject];                               }              else {                  nslog(@"access denied 2");                  nslog(@"%@", [error description]);              }          }];      } else {          nslog(@"error: %@", [e description]);          nslog(@"access denied");      }  }]; } 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -