我只想获取特定Twitter帐户的所有推文。我想使用下面的url,但不知道我们如何获得twitter帐户的user_id或screen_name,我们想要获取它的推文。获取特定Twitter帐户的所有推文?
资源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];
}];
}
}
}];
}
我无法接收的阵列所有推文。
您是否可以再次查看我编辑的内容。 –
由于最近的Twitter更改,json是目前唯一可用的格式:https://dev.twitter.com/docs/api/1.1/overview#New_Twitter_client_policies – alairock