如何检索朋友';使用facebook connect with iphone应用程序列出
我正在为我的iphone应用程序使用facebook connect。它能够对用户进行身份验证,还可以在用户的墙上发布评论。但我不知道如何检索用户的好友列表。一个示例代码将非常感谢 提前感谢,如何检索朋友';使用facebook connect with iphone应用程序列出,iphone,facebook,Iphone,Facebook,我正在为我的iphone应用程序使用facebook connect。它能够对用户进行身份验证,还可以在用户的墙上发布评论。但我不知道如何检索用户的好友列表。一个示例代码将非常感谢 提前感谢, -Chandni在实现FBRequestDelegate和FBSessionDelegate的类中执行以下操作: -(void) getFriends{ NSString * funcName = @"friends.get"; [[FBRequest requestWit
-Chandni在实现FBRequestDelegate和FBSessionDelegate的类中执行以下操作:
-(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];
}
在实现FBRequestDelegate和FBSessionDelegate的类中,执行以下操作:
-(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];
}
使用此方法调用您的
getFriends
方法
- (void)request:(FBRequest*)request didLoad:(id)result
使用此方法调用您的
getFriends
方法
- (void)request:(FBRequest*)request didLoad:(id)result
这就是我将好友列表输出到控制台的方法。我仍在想如何向他们的一堵墙发送信息
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
//Call the request method
[[delegate facebook] requestWithGraphPath:@"me/friends" andDelegate:self];
// get the array of friends
NSArray *data = [result objectForKey:@"data"];
// Check that the user has friends
if ([data count] > 0) {
NSMutableArray *array = [NSMutableArray array];
for (int i = 0; i < data.count; i++){
id object = [data objectAtIndex:i];
[array addObject:[object objectForKey:@"name"]];
}
NSLog(@"list of friends %@", array);
AppDelegate*delegate=(AppDelegate*)[[UIApplication sharedApplication]delegate];
//调用请求方法
[[delegate facebook]requestWithGraphPath:@“我/朋友”和delegate:self];
//获取好友数组
NSArray*数据=[result objectForKey:@“数据”];
//检查用户是否有朋友
如果([数据计数]>0){
NSMutableArray*数组=[NSMutableArray];
对于(int i=0;i
这是我将好友列表输出到控制台时所做的操作。不过,我仍在尝试如何将消息发送到他们的某一面墙
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
//Call the request method
[[delegate facebook] requestWithGraphPath:@"me/friends" andDelegate:self];
// get the array of friends
NSArray *data = [result objectForKey:@"data"];
// Check that the user has friends
if ([data count] > 0) {
NSMutableArray *array = [NSMutableArray array];
for (int i = 0; i < data.count; i++){
id object = [data objectAtIndex:i];
[array addObject:[object objectForKey:@"name"]];
}
NSLog(@"list of friends %@", array);
AppDelegate*delegate=(AppDelegate*)[[UIApplication sharedApplication]delegate];
//调用请求方法
[[delegate facebook]requestWithGraphPath:@“我/朋友”和delegate:self];
//获取好友数组
NSArray*数据=[result objectForKey:@“数据”];
//检查用户是否有朋友
如果([数据计数]>0){
NSMutableArray*数组=[NSMutableArray];
对于(int i=0;i
非常感谢!!!我今天就试试。。我还假设FBConnect没有任何默认页面来显示iPhone的好友列表,以及他们必须发布的方式,以及登录到so David,他将调用getFriends方法。非常感谢!!!我今天就试试。。我还假设FBConnect没有任何默认页面来显示好友列表对于iPhone,他们发布和登录的方式是不一样的,大卫将调用getFriends方法