[英]Fetching Facebook friends with Graph API
I am trying to retrieve the list of facebook friends of a logged user in an Iphone app. 我试图在Iphone应用程序中检索已登录用户的facebook好友列表。
this is the code I am using 这是我正在使用的代码
[_facebook requestWithGraphPath:@"me/friends" andDelegate:self];
the result I get is a NSDictionary instance with only an object inside. 我得到的结果是一个NSDictionary实例,里面只有一个对象。
Am I doing something wrong? 难道我做错了什么?
You parse your DIctionary Data. 您解析您的DIctionary数据。
Sample code here, 示例代码在这里,
if ([result isKindOfClass:[NSDictionary class]]) {
NSArray *userInfoArray=[result objectForKey:@"data"];
NSMutableArray *userIdArray=[[NSMutableArray alloc ]init];
NSMutableArray *userNameArray=[[NSMutableArray alloc ]init];
for (int indexVal=0; indexVal<[userInfoArray count]; indexVal++) {
NSDictionary *individualUserInfo=[userInfoArray objectAtIndex:indexVal];
[userIdArray addObject:[individualUserInfo objectForKey:@"id"]];
[userNameArray addObject:[individualUserInfo objectForKey:@"name"]];
}
NSLog(@"Frnd Name Array : %@ ",userNameArray);
NSLog(@"Id Array : %@ ",userIdArray);
}
Here result is the data you received in request:DidLoad delegate method 结果是您在请求中收到的数据:DidLoad委托方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.