Fetch Facebook friend list using SLRequest in ios 6.0

后端 未结 2 1750
误落风尘
误落风尘 2021-02-02 02:18

I integrated facebook in ios 6.0 as decribed

How to integrate Facebook in iOS 6 using SLRequest?

But I am not able to fetch the facebook friend list using SLRequ

2条回答
  •  庸人自扰
    2021-02-02 02:29

    I figured it how it should work.

    The below code is working fine for me.

     NSArray *accounts = [accountStore
                                   accountsWithAccountType:facebookAccountType];
              ACAccount *facebookAccount = [accounts lastObject];
              NSString *acessToken = [NSString stringWithFormat:@"%@",facebookAccount.credential.oauthToken];
              NSDictionary *parameters = @{@"access_token": acessToken};
              NSURL *feedURL = [NSURL URLWithString:@"https://graph.facebook.com/me/friends"];
              SLRequest *feedRequest = [SLRequest
                                        requestForServiceType:SLServiceTypeFacebook
                                        requestMethod:SLRequestMethodGET
                                        URL:feedURL
                                        parameters:parameters];
              feedRequest.account = facebookAccount;
              [feedRequest performRequestWithHandler:^(NSData *responseData,
                                                       NSHTTPURLResponse *urlResponse, NSError *error)
               {
                   NSLog(@"%@",[[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]);
               }];
          }
          else
          {
              // Handle Failure
          }
    

提交回复
热议问题