iPhone- Twitter API GET Users Followers/Following

前端 未结 3 723
隐瞒了意图╮
隐瞒了意图╮ 2020-12-24 03:52

I want to be able to use the Twitter API for ios 5 to get all of the user followers and following user name into a NSDictionary...

I\'ve hit a road bloc

3条回答
  •  庸人自扰
    2020-12-24 04:45

    Use FHSTwitterEngine

    #import "FHSTwitterEngine.h"

    Add SystemConfiguration.framework

    Write following code to your viewDidLoad(for oauth login)

    UIButton *logIn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    logIn.frame = CGRectMake(100, 100, 100, 100);
    [logIn setTitle:@"Login" forState:UIControlStateNormal];
    [logIn addTarget:self action:@selector(showLoginWindow:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:logIn];
    
    [[FHSTwitterEngine sharedEngine]permanentlySetConsumerKey:@"Xg3ACDprWAH8loEPjMzRg" andSecret:@"9LwYDxw1iTc6D9ebHdrYCZrJP4lJhQv5uf4ueiPHvJ0"];
    [[FHSTwitterEngine sharedEngine]setDelegate:self];
    
    
     - (void)showLoginWindow:(id)sender {
    UIViewController *loginController = [[FHSTwitterEngine sharedEngine]loginControllerWithCompletionHandler:^(BOOL success) {
        NSLog(success?@"L0L success":@"O noes!!! Loggen faylur!!!");
        [[FHSTwitterEngine sharedEngine]loadAccessToken];
        NSString *username = [FHSTwitterEngine sharedEngine].authenticatedUsername;
        NSLog(@"user name is :%@",username);
        if (username.length > 0) {
            [self listResults];
        }
    }];
         [self presentViewController:loginController animated:YES completion:nil];
    }
     - (void)listResults {
    
    NSString *username = [FHSTwitterEngine sharedEngine].authenticatedUsername;
    NSMutableDictionary *   dict1 = [[FHSTwitterEngine sharedEngine]listFriendsForUser:username isID:NO withCursor:@"-1"];
    
    //  NSLog(@"====> %@",[dict1 objectForKey:@"users"] );        // Here You get all the data
    NSMutableArray *array=[dict1 objectForKey:@"users"];
    for(int i=0;i<[array count];i++)
    {
        NSLog(@"names:%@",[[array objectAtIndex:i]objectForKey:@"name"]);
    }
    }
    

提交回复
热议问题