开发者

want to fetch the friends list of facebook thorough fbconnect in iphone using objective-c?

开发者 https://www.devze.com 2022-12-12 14:09 出处:网络
how to fetch the friends list of facebook in iphone through fbconnect in objective-c? I am using this code

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"];
   开发者_JS百科           _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.


You spelled @"facebook.freinds.get" incorrectly.

friends != freinds

http://wiki.developers.facebook.com/index.php/FQL_Tables Check out this reference.

0

精彩评论

暂无评论...
验证码 换一张
取 消