在我的应用程序中,我想在未登录 twitter 帐户进入 iPhone 的设置时从 twitter 获取推文。实际上我只收到用户推文(我发推文)。但我想获得所有关注者的推文。
我正在使用这个网址:http ://api.twitter.com/1/statuses/user_timeline.json
我改为:http ://api.twitter.com/1/statuses/home_timeline.json 发生错误。错误是:由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“ * -[__NSArrayM insertObject:atIndex:]: object cannot be nil”
我正在使用这段代码。
- (IBAction)twitterButtonPressed:(UIButton *)sender
{
[self.usernameTextField resignFirstResponder];
self.nameString = self.usernameTextField.text;
NSURL *timelineUrl = [NSURL URLWithString:@"http://api.twitter.com/1/statuses/home_timeline.json"];
NSMutableDictionary *parameters =
[[NSMutableDictionary alloc] init];
[parameters setObject:self.nameString forKey:@"screen_name"];
[parameters setObject:@"50" forKey:@"count"];
[parameters setObject:@"1" forKey:@"include_entities"];
SLRequest *postRequest = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodGET URL:timelineUrl parameters:parameters];
[postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error)
{
if (responseData != nil)
{
NSError *error = nil;
self.dataSource = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableLeaves error:&error];
NSLog(@" tweet inindex 0 %@",[self.dataSource valueForKey:@"text"]);
NSLog(@"ghjgjhdgjhdgjsgdjgsdjg %d",dataSource.count);
if (self.dataSource.count)
{
[self performSelectorOnMainThread:@selector(homeView) withObject:nil waitUntilDone:YES];
}
}
}];
}