在我的应用程序中,我想向Twitter friend 发送直接消息以邀请其使用该应用程序。为了发送直接消息,我需要目标人员关注用户。但是我不想列出所有关注者,而只列出用户也关注的关注者。有没有办法在iOS中获取此列表?
谢谢
最佳答案
使用FHSTwitterEngine
#导入“FHSTwitterEngine.h”
添加 SystemConfiguration.framework
将以下代码写入您的viewDidLoad(用于oauth登录)
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"]);
}
}
关于ios - 在iOS上,如何获取用户也在Twitter上关注的关注者列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24281496/