how to fetch the friends list of facebook in iphone through fbconnect in objective-c?
I am using this code
(void)getUserName
{
NSString *fql = [NSString localizedStringWithFormat: @"SELECT uid FROM user WHERE is_app_user = 1 AND uid IN (SELECT uid2 FROM friend WHERE uid1 = %lld)",[FBSession session].uid];
NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"];
[[FBRequest requestWithDelegate:self] call:@"facebook.friends.get" params:params];
}
- (void)request:(FBRequest*)request didLoad:(id)result {
if ([request.method isEqualToString:@"facebook.fql.query"]) {
NSArray* users = result;
NSDictionary* user = [users objectAtIndex:0];
NSString* name = [user objectForKey:@"name"];
_label.text = [NSString stringWithFormat:@"Logged in as %@", name];
} else if ([request.method isEqualToString:@"facebook.users.setStatus"]) {
NSString* success = result;
if ([success isEqualToString:@"1"]) {
_label.text = [NSString stringWithFormat:@"Status successfully set"];
} else {
_label.text = [NSString stringWithFormat:@"Problem setting status"];
}
} else if ([request.method isEqualToString:@"facebook.freinds.get"])
{
if(myList==nil)
{
NSArray* users = result;
myList =[[NSArray alloc] initWithArray: users];
for(NSInteger i=0;i<[users count];i++) {
NSDictionary* user = [users objectAtIndex:i];
NSString* uid = [user objectForKey:@"uid"];
NSString* fql = [NSString stringWithFormat:
@"select name from user where uid == %@", uid];
NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"];
[[FBRequest requestWithDelegate:self] call:@"facebook.fql.query" params:params];
}
}
else {
NSArray* users = result;
NSDictionary* user = [users objectAtIndex:0];
NSString* name = [user objectForKey:@"name"];
//txtView.text=[NSString localizedStringWithFormat:@"%@%@,\n",txtView.text,name];
NSLog(name);
}}
I want to get the friends list from facebook and then search/modify then add it to my addressbook.
I know this code is doing this but I don't know how to use it or where do I
use it.. If you could please post something or just elaborate on how do I use
your code thru fbconnect framework. I have implemented upto get permissions
and publish feeds one's wall.
But please can you post here about the layout details of the results, like
what do Ineed to use on the layout point of view.