我只想获取特定 Twitter 帐户的所有推文。我想使用下面的 url,但不知道如何获取 Twitter 帐户的 user_id 或 screen_name,我们想要获取其推文。
资源 URL http://api.twitter.com/1/statuses/user_timeline.format参数 请求用户时间线时始终指定 user_id 或 screen_name。
有没有人有任何想法或源代码或参考。任何帮助都将是非常可观的。
我正在使用以下函数来获取 200 条推文,但它显示在 NSLog 中
HTTP 响应状态:403 消息
功能
- (IBAction)followOnTwitter:(id)sender
{
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[accountStore requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error) {
if(granted) {
// Get the list of Twitter accounts.
NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];
// For the sake of brevity, we'll assume there is only one Twitter account present.
// You would ideally ask the user which account they want to tweet from, if there is more than one Twitter account present.
if ([accountsArray count] > 0) {
// Grab the initial Twitter account to tweet from.
ACAccount *twitterAccount = [accountsArray objectAtIndex:0];
NSMutableDictionary *tempDict = [[NSMutableDictionary alloc] init];
[tempDict setValue:@"rohit40793982" forKey:@"screen_name"];
//[tempDict setValue:@"true" forKey:@"follow"];
// [tempDict setValue:@"683286" forKey:@"user_id "];
TWRequest *postRequest = [[TWRequest alloc] initWithURL:[NSURL URLWithString:@"http://api.twitter.com/1/statuses/user_timeline.format"]
parameters:tempDict
requestMethod:TWRequestMethodPOST];
[postRequest setAccount:twitterAccount];
[postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSLog(@"%@",urlResponse);
tweets = [NSJSONSerialization JSONObjectWithData:responseData
options:kNilOptions
error:&error];
NSString *output = [NSString stringWithFormat:@"HTTP response status: %i", [urlResponse statusCode]];
NSLog(@"%@", output);
[self performSelectorOnMainThread:@selector(displayText:) withObject:output waitUntilDone:NO];
}];
}
}
}];
}
我没有收到所有推文的数组。