2012-03-17 5 views
0

나는 트위터 클라이언트 애플 리케이션을 만들기 위해 노력하고 있습니다. 클라이언트의 요구 사항 중 하나는 특정 짹짹을 앱에서 좋아하는 것으로 표시하는 것입니다. 나는 이것을 2 일 동안 찾지 만 단서는 없다. 만약 ios 5의 twitter API를 통해 그렇게 할 수 있다면 plz이 나를 안내 할 수 있을까? 그렇다면 어떻게?iOS 5 트위터 API를 통해 짹짹 좋아하는 만들기

답변

2

예는 트위터를 사용 가능 이잖아 및 계정 프레임 워크 :

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]; 


      NSString* urlString = [NSString stringWithFormat:@"http://api.twitter.com/1/favorites/create/%d.json", tweetID]; 
      TWRequest *postRequest = [[TWRequest alloc] initWithURL:[NSURL URLWithString:urlString] 
              parameters:nil 
              requestMethod:TWRequestMethodPOST]; 


      [postRequest setAccount:twitterAccount]; 

      [postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { 
       NSString *output = [NSString stringWithFormat:@"HTTP response status: %i", [urlResponse statusCode]]; 
       NSLog(@"%@", output); 

      }]; 

      } 
     } 
    }]; 
} 

또한 트위터 REST API 문서에서 살펴 : https://dev.twitter.com/docs/api/1/post/favorites/create/%3Aid

+0

감사 남자 !!!!!!!!! 정말 불행했습니다 ....... – sns