Retweet, reply and favorite in iOS 5 Twitter with the Accounts framework

后端 未结 3 1366
温柔的废话
温柔的废话 2021-01-31 00:11

I have integrated iOS 5 Twitter in my application. I am able to send tweets by TWTweetComposeViewController with the integration of Twitter and Accounts framework.<

3条回答
  •  南笙
    南笙 (楼主)
    2021-01-31 01:07

    Use following code for retweeting.

    - (void)_retweetMessage:(TwitterMessage *)message
    {
        NSString *retweetString = [NSString stringWithFormat:@"http://api.twitter.com/1/statuses/retweet/%@.json", message.identifier];
        NSURL *retweetURL = [NSURL URLWithString:retweetString];
        TWRequest *request = [[TWRequest alloc] initWithURL:retweetURL parameters:nil requestMethod:TWRequestMethodPOST];
        request.account = _usedAccount;
    
        [request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
            if (responseData)
            {
                NSError *parseError = nil;
                id json = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:&parseError];
    
                if (!json)
                {
                    NSLog(@"Parse Error: %@", parseError);
                }
                else
                {
                    NSLog(@"%@", json);
                }
            }
            else
            {
                NSLog(@"Request Error: %@", [error localizedDescription]);
            }
        }];
    }
    

    Taken From Here

    Good Luck.

提交回复
热议问题