2012-03-17 15 views
0

私はTwitterクライアントアプリケーションを作っています。クライアントの要件の1つは、特定のつぶやきをアプリからお気に入りとしてマークすることです。私は2日間これを探していますが、手掛かりはありません..もしios 5のtwitter APIを使ってそうすることができれば、どんなplzでも私を導くことができますか?はいの場合はどうですか?iOS 5 twitter APIでツイートのお気に入りを作る

答えて

2

はいTwitterをご利用可能thatsのとアカウントのフレームワーク:

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

      }]; 

      } 
     } 
    }]; 
} 

またTwitterのREST APIドキュメントを見てみましょう:https://dev.twitter.com/docs/api/1/post/favorites/create/%3Aid

+0

おかげで男が!!!!!!!!!それは本当にハーフフルだった....... – sns

関連する問題