2012-05-15 5 views
1

특정 트위터 계정의 모든 트윗을 가져오고 싶습니다. 나는 아래 URL을 사용하고 싶지만 우리가 가져오고 싶은 tweet의 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]; 

       }]; 
      } 
     } 
    }]; 
} 

I가 수신되지 않는 배열을 모든 트윗.

답변

3

당신의 실수 : 내가 두려워 자바 프로그래머가 내가 더 도울 수 있어요으로

을 (난 그냥 API를 읽어 사용자의 타임 라인을 점점 XML 반환을 허용하지 않는 생각) 제 생각에는이 줄을 가지고 있습니다

http://api.twitter.com/1/statuses/user_timeline.format 

".format"은 응답하려는 형식입니다. 당신이 XML을 원하는 경우 예를 들어,

https://api.twitter.com/1/statuses/user_timeline.xml 

또는 JSON에 대한

은 또한 쿼리로 SCREEN_NAME를 추가해야합니다

https://api.twitter.com/1/statuses/user_timeline.json 

를 사용하여 사용합니다. 예를 들어, JSON으로 내 트윗을 모두 얻을 u는 내가 편집 한 것에 대해 다시 모습을 가질 수

https://api.twitter.com/1/statuses/user_timeline.xml?screen_name=edent 
1

기본적으로 계정 이름입니다. '@'바로 뒤에 오는 이름입니다. 와우의 screen_name은 @Warcraft와 같습니다.

아, 실제로 .format이 문제였습니다. 3 : atom, json 또는 xml 중 하나를 지정해야합니다./

+0

사용할 수 있습니다. –

+0

최근 트위터 변경으로 인해 json 만 현재 사용할 수있는 형식입니다. https://dev.twitter.com/docs/api/1.1/overview#New_Twitter_client_policies – alairock

관련 문제