[英]Cannot get data for the twitter timeline
I am trying to load the tweets through json since I am currently making an twitter app. 我正在尝试通过json加载这些推文,因为我当前正在制作一个Twitter应用程序。 No sign of getting data from json twitter. 没有从json twitter获取数据的迹象。 I also have an null output from my array as well. 我的数组也有一个空输出。 Is there a possible mistake that I made using the API? 我使用API可能会犯错误吗?
-(void)twitterTimeLine{
ACAccountStore *account = [[ACAccountStore alloc]init];
ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[account requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error)
{
if (granted == YES) {
NSArray *arrayOfAccounts = [account accountsWithAccountType:accountType];
if ([arrayOfAccounts count] > 0) {
ACAccountType *twitterAccount = [arrayOfAccounts lastObject];
NSURL *requestAPI = [NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/home_timeline/json"];
NSMutableDictionary *parameters = [[NSMutableDictionary alloc]init];
[parameters setObject:@"100" forKey:@"count"];
[parameters setObject:@"1" forKey:@"include_entities"];
SLRequest *posts = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodGET URL:requestAPI parameters:parameters];
posts.account = (ACAccount *)twitterAccount;
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
[posts performRequestWithHandler:^(NSData *response, NSHTTPURLResponse *urlResponse, NSError *error){
array=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&error];
// NSLog(@"%@",posts);
NSLog(@"%@",array);
NSLog(@"---------");
if (array.count !=0) {
dispatch_async(dispatch_get_main_queue(),^{
[timelineTableView reloadData];
});
}
}];
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}
else {
NSLog(@"%@", [error localizedDescription]);
}
};
}];
Try this : 尝试这个 :
ACAccount *twitterAccount = [arrayOfAccounts lastObject];
This might be the reason of getting warning. 这可能是得到警告的原因。
Update your URL with : 使用以下命令更新您的URL:
https://api.twitter.com/1.1/statuses/home_timeline.json https://api.twitter.com/1.1/statuses/home_timeline.json
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.