如何使用Facebook连接iPhone应用程序检索朋友的名单 [英] how to retrieve friends' list using facebook connect with iphone app

查看:81
本文介绍了如何使用Facebook连接iPhone应用程序检索朋友的名单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的iPhone应用程序使用的是facebook connect.它能够对用户进行身份验证,也可以在用户的​​墙上发布评论.但是我不确定如何检索用户的朋友列表.示例代码将不胜感激.

I'm using facebook connect for my iphone app. It is able to authenticate the user and also publish a comment on the user's wall. But I'm not sure how to retrieve the user's friends list. A sample code will be highly appreciated.

预先感谢

-钱德尼

推荐答案

在实现FBRequestDelegate和FBSessionDelegate的类中,请执行以下操作:

In a class that implements the FBRequestDelegate and FBSessionDelegate do this:

-(void) getFriends{
        NSString * funcName = @"friends.get";
        [[FBRequest requestWithDelegate:self] call:funcName params:nil];
}

- (void) processFriendsQuery:(id) result{
   friends = [[NSMutableArray alloc] init];
    NSString * element; 
    gDatabase.userIdList = [[[NSMutableArray alloc] initWithCapacity:MAX_FRIENDS_LIST] autorelease];     

 for (element in result){
    Friend * aFriend = [[[Friend alloc] init]autorelease];  
     NSString * uid = [self dictionaryToUID:element];
     aFriend.userId = (NSMutableString *)  uid;
     [gDatabase.userIdList addObject:aFriend.userId];        
 }      

然后调用

- (void)request:(FBRequest*)request didLoad:(id)result {
  [self processFriendsQuery:result];    
}

这篇关于如何使用Facebook连接iPhone应用程序检索朋友的名单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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