在ios 6.0中使用SLRequest获取Facebook好友列表 [英] Fetch Facebook friend list using SLRequest in ios 6.0

查看:124
本文介绍了在ios 6.0中使用SLRequest获取Facebook好友列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将ios 6.0中的facebook集成为

I integrated facebook in ios 6.0 as decribed

如何使用SLRequest在iOS 6中集成Facebook?

但是我无法取得Facebook使用SLRequest的好友列表。任何人都可以知道如何做到这一点?我想在我的游戏中实现与朋友一起玩的功能。

But I am not able to fetch the facebook friend list using SLRequest . Can anyone know how to do this? I want to implement "Play with Friends" kind of features in my game.

谢谢

推荐答案

我认为它应该如何运作。

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
      }

这篇关于在ios 6.0中使用SLRequest获取Facebook好友列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆