iphone - I get the Malformed access token for Facebook in ios 6 -


i want fetch facebook friends profile picture.i give access_token it.

i search lot on net didn't got solution.

my code follow:

- (ibaction)advancedbuttonpressed:(id)sender {      self.accountstore = [[acaccountstore alloc]init];     acaccounttype *fbaccounttype= [self.accountstore accounttypewithaccounttypeidentifier:acaccounttypeidentifierfacebook];      //nsstring *key = @"xxxxxx";      nsstring *key = @"xxxxxx";     nsdictionary *dictfb = [nsdictionary dictionarywithobjectsandkeys:key,acfacebookappidkey,@[@"email"],acfacebookpermissionskey, nil];           [self.accountstore requestaccesstoaccountswithtype:fbaccounttype options:dictfb completion:          ^(bool granted, nserror *e) {              if (granted) {                  nsarray *accounts = [self.accountstore accountswithaccounttype:fbaccounttype];                  //it last object single sign on                  self.facebookaccount = [accounts lastobject];                     nslog(@"facebook account =%@",self.facebookaccount);                   acaccountcredential *fbcredential = [self.facebookaccount credential];                 accesstoken = [fbcredential oauthtoken];                  nslog(@"facebook access token: %@", accesstoken);                   [self get];              } else {                  //fail gracefully...               nslog(@"error getting permission %@",e);               }          }];  }   -(void)fr { nsurl *requesturl = [nsurl urlwithstring:@"https://graph.facebook.com/me/friends?fields=id,name,picture,first_name,last_name,gender&access_token=baafcrqzczaueubaicacm2q1v5uzrhee6xhgnbedu19v6czbiedjmtwhbktmzbwtvufieeuxqt4ykeskei17qzbgazceszbfokdbzafr4e9rn2nfqhalkpxzbga96wqcu8csng4zcjck1v7jibqzaprgnl6mjjo4ns1cealpbxuytum1cxbnqttt82ypvvkozcmmebpqhfwymx1oku9rzbsjpza6dlhka1ugyu32egj8qoqzasjvqzdzd"];      slrequest *request = [slrequest requestforservicetype:slservicetypefacebook                                             requestmethod:slrequestmethodget                                                       url:requesturl                                                parameters:nil];     request.account = self.facebookaccount;        [request performrequestwithhandler:^(nsdata *data,                                          nshttpurlresponse *response,                                          nserror *error) {          if(!error)         {             list =[nsjsonserialization jsonobjectwithdata:data options:kniloptions error:&error];              nslog(@"dictionary contains data: %@", list );             if([list objectforkey:@"error"]!=nil)             {                 [self attemptrenewcredentials];             }             dispatch_async(dispatch_get_main_queue(),^{                 namelabel.text = [list objectforkey:@"username"];             });         }         else{             //handle error gracefully             nslog(@"error get%@",error);             //attempt revalidate credentials         }      }]; } 

but got error this:

error =     {         code = 190;         message = "malformed access token baafcrqzczaueubaicacm2q1v5uzrhee6xhgnbedu19v6czbiedjmtwhbktmzbwtvufieeuxqt4ykeskei17qzbgazceszbfokdbzafr4e9rn2nfqhalkpxzbga96wqcu8csng4zcjck1v7jibqzaprgnl6mjjo4ns1cealpbxuytum1cxbnqttt82ypvvkozcmmebpqhfwymx1oku9rzbsjpza6dlhka1ugyu32egj8qoqzasjvqzdzd?access_token=baafcrqzczaueubahbzbsdtl9wwfdovthxj78bbjlrnekpikhdxza1harmo9dtbtjdszctzcu2vae5byzadk7ox30bpir0ktg0zc6pi1ioe0knzczbsxqbycg0c6ws5ct4ferl3g0vu1wifdypkekfm3zb4r5gaiureq66yuz2fu2mp5ngqzcbe1p357h41p2lkoaqn9ezamu4q3srtjmuviw4dtdc00l4rhmudwtoiuqlo54bgzdzd";         type = oauthexception;     }; } 

i can't able solve this. me!

if you're using slrequest, auto append access token you, , should not have request params in url itself. instead, should like:

nsurl *requesturl = [nsurl urlwithstring:@"https://graph.facebook.com/me/friends"];  slrequest *request = [slrequest requestforservicetype:slservicetypefacebook                                         requestmethod:slrequestmethodget                                                   url:requesturl                                            parameters:@{@"fields":@"id,name,picture,first_name,last_name,gender"}]; 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -