7

私はFacebookを自分のiOSアプリに統合しています。Facebookの友達をテーブルビューに読み込んで、友だちを招待する方法友達との言葉。Facebookの友人をUITableViewにロードする

私は、[facebook requestWithGraphPath:@"me/friends" andDelegate:self]; がFacebookからの友人をリクエストしていますが、そこから何をすべきかを判断することはできません。どういうわけか私は友達のIDを取得してメッセージを送ることができます。 情報やアドバイスをいただければ幸いです。あなたが一度にすべてのプロファイルの写真で、ユーザーの友人を取得したい場合は、事前

+0

さらに検索して問題を解決しました。誰でも検索するには、ここに答えがありますhttp://stackoverflow.com/questions/6491838/retrieve-facebook-friends-list –

答えて

4
- (void)getFriendsResponse { 
    FbGraphResponse *fb_graph_response = [fbGraph doGraphGet:@"me/friends" withGetVars:nil];// me/feed 
//parse our json 
    SBJSON *parser = [[SBJSON alloc] init]; 
    NSDictionary * facebook_response = [parser objectWithString:fb_graph_response.htmlResponse error:nil]; 
    //init array 
     NSMutableArray * feed = (NSMutableArray *) [facebook_response objectForKey:@"data"]; 
     NSMutableArray *recentFriends = [[NSMutableArray alloc] init]; 

     //adding values to array 
     for (NSDictionary *d in feed) { 

      NSLog(@"see Dicitonary :%@",d); 
      facebook = [[Facebook alloc]initWithFacebookDictionary:d ]; 
      [recentFriends addObject:facebook]; 
      NSLog(@"Postsss :->>>%@",[facebook sender]); 

      [facebook release]; 
     } 

     friends = recentFriends; 

     [self.tableView reloadData]; 
    } 

に感謝し、テーブルビュー

3

で、その後ショーにNSArrayあなたはこれを試すことができます。まず:

- (void) requestFriends:(NSNumber *) fbUserId 
{ 
    NSLog(@"requesting friends"); 

    NSString* fql1 = [NSString stringWithFormat: 
         @"select uid2 from friend where uid1 = %@", fbUserId ]; 
    NSString* fql2 = [NSString stringWithFormat: 
         @"select uid, name, pic_small from user where uid in (select uid2 from #queryID) order by name"]; 
    NSString* fql = [NSString stringWithFormat: 
        @"{\"queryID\":\"%@\",\"queryUser\":\"%@\"}",fql1,fql2]; 

    NSLog(fql); 

    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObject:fql forKey:@"queries"]; 

    [_facebook requestWithMethodName:@"fql.multiquery" andParams:params andHttpMethod:@"GET" andDelegate:self]; 
} 

あなたは答えを得るときに、それを処理する:

-(void) processFriends:(id) result 
{ 
    //NSLog(@"processFriends %@", result); 
    NSArray *queryResults = (NSArray*) result; 
    NSMutableDictionary *firstQuery = [queryResults objectAtIndex:0]; 
    NSMutableDictionary *secondQuery = [queryResults objectAtIndex:1]; 

    NSArray *resultSet1 = [firstQuery objectForKey:@"fql_result_set"]; 
    NSString *resultName1 = [firstQuery objectForKey:@"name"]; 

    NSArray *resultSet2 = [secondQuery objectForKey:@"fql_result_set"]; 
    NSString *resultName2 = [secondQuery objectForKey:@"name"]; 

    NSLog(@"%@\n\%@", resultName2, resultSet2); 

} 

基本的resultSet2は、各友人の辞書ではこれらのキーを持つそれぞれが友人を含むエントリの配列であり、 : --uid - 名前 - pic_small

あなたが必要なものはすべてあります。 お手伝い願います!

関連する問題