Ios 使用Fabric从twitter获取所有关注者的列表
使用fabric从twitter sdk获取追随者列表,但无法获取超过20个追随者。另一个限制是需要先获得所有追随者,然后上传到api。我正在使用下面的代码获取追随者列表。请指导在现有代码中需要做哪些更改,或者需要转换到一些新的方式Ios 使用Fabric从twitter获取所有关注者的列表,ios,iphone,twitter,twitter-fabric,Ios,Iphone,Twitter,Twitter Fabric,使用fabric从twitter sdk获取追随者列表,但无法获取超过20个追随者。另一个限制是需要先获得所有追随者,然后上传到api。我正在使用下面的代码获取追随者列表。请指导在现有代码中需要做哪些更改,或者需要转换到一些新的方式 ACAccountStore *accountStore = [[ACAccountStore alloc] init]; ACAccountType *accountType = [accountStore accountTypeWithAccou
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error){
if (granted) {
//[MBProgressHUD showHUDAddedTo:self.view animated:YES];
NSArray *accounts = [accountStore accountsWithAccountType:accountType];
// Check if the users has setup at least one Twitter account
if (accounts.count > 0)
{
ACAccount *twitterAccount = [accounts objectAtIndex:0];
// Creating a request to get the info about a user on Twitter
SLRequest *twitterInfoRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodGET URL:[NSURL URLWithString:@"https://api.twitter.com/1.1/followers/list.json"] parameters:[NSDictionary dictionaryWithObject:twitterAccount.username forKey:@"screen_name"]];
[twitterInfoRequest setAccount:twitterAccount];
// Making the request
[twitterInfoRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
// Check if we reached the reate limit
if ([urlResponse statusCode] == 429) {
NSLog(@"Rate limit reached");
return;
}
if (error) {
NSLog(@"Error: %@", error.localizedDescription);
return;
}
// Check if there is some response data
if (responseData) {
NSError *error = nil;
NSArray *TWData = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableLeaves error:&error];
// Filter the preferred data
NSArray *arrFollowList = [TWData valueForKey:@"users"];
// Filter the preferred data
NSMutableArray *arrFollowersList = [[NSMutableArray alloc]init];
for(int i =0; i<[arrFollowList count]; i++)
{
NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
[dict setObject:[[arrFollowList objectAtIndex:i] valueForKey:@"name"] forKey:@"FriendName"];
[dict setObject:@"" forKey:@"Email"];
[dict setObject:strType forKey:@"FriendType"];
[dict setObject:[[arrFollowList objectAtIndex:i] valueForKey:@"id"] forKey:@"UserAccountId"];
//[dict setObject:@"" forKey:@"UserAccountId"];
[dict setObject:@"1" forKey:@"Team_Id"];
[dict setObject:[[arrFollowList objectAtIndex:i] valueForKey:@"profile_image_url"] forKey:@"ProfileImage"];
[arrFollowersList addObject:dict];
}
NSString *teamId = @"1";
NSDictionary *objDict = [NSDictionary dictionaryWithObjectsAndKeys:
teamId, @"Team_Id",
arrFollowersList, @"userFriendList",
nil];
NSLog(@"dict %@",objDict);
[iOSRequest postData:[NSString stringWithFormat:@"%@", kFriendListUpdateUrl] :objDict :^(NSDictionary *response_success)
{
NSLog(@"response_success:%@", response_success);
if([[response_success valueForKey:@"message"] isEqualToString:@"Success"])
{
NSMutableDictionary *dictSquads = [[NSMutableDictionary alloc]init];
[dictSquads setObject:[standardDefaults valueForKey:@"UserId"] forKey:@"User_Id"];
[dictSquads setObject:@"1" forKey:@"Team_Id"];
[dictSquads setObject:strType forKey:@"FriendType"];
}
}
:^(NSError *response_error)
{
}];
}
});
}];
}
} else {
NSLog(@"No access granted");
[MBProgressHUD hideAllHUDsForView:self.view animated:YES];
}
}];
ACAccountStore*accountStore=[[ACAccountStore alloc]init];
ACAccountType*accountType=[accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierWitter];
[accountStore requestAccessToAccountsWithType:accountType选项:无完成:^(已授予BOOL,n错误*错误){
如果(授予){
//[MBProgressHUD showhud addedto:self.view动画:是];
NSArray*accounts=[accountStore accountsWithAccountType:accountType];
//检查用户是否至少设置了一个Twitter帐户
如果(accounts.count>0)
{
ACAccount*twitterAccount=[accounts objectAtIndex:0];
//创建请求以获取Twitter上用户的信息
SLRequest*twitterInfoRequest=[SLRequestRequestForService类型:SLServiceTypeTwitterRequestMethod:SLRequestMethodGET URL:[NSURL URLWithString:@]https://api.twitter.com/1.1/followers/list.json“]参数:[NSDictionary Dictionary WithObject:twitterAccount.username forKey:@“screen_name”];
[twitterInfoRequest设置帐户:twitterAccount];
//提出请求
[twitterInfoRequest performRequestWithHandler:^(NSData*responseData,NSHTTPURLRResponse*urlResponse,NSError*错误){
dispatch\u async(dispatch\u get\u main\u queue()^{
//检查我们是否达到创建限制
if([urlResponse statusCode]==429){
NSLog(“达到速率限制”);
返回;
}
如果(错误){
NSLog(@“Error:%@”,Error.localizedDescription);
返回;
}
//检查是否有一些响应数据
如果(响应数据){
n错误*错误=nil;
NSArray*TWData=[NSJSONSerialization JSONObjectWithData:responseData选项:NSJSONReadingMutableLeaves错误:&error];
//筛选首选数据
NSArray*arrFollowList=[TWData valueForKey:@“users”];
//筛选首选数据
NSMutableArray*arrFollowersList=[[NSMutableArray alloc]init];
对于(int i=0;i