如何使用STTwitter向Twitter用户发布回复

时间:2014-04-21 02:40:33

标签: ios twitter sttwitter

我在发布对特定状态ID的回复时遇到问题

这是我的身份验证码

twitterWithReply = [STTwitterAPI twitterAPIOSWithFirstAccount];

[twitterWithReply verifyCredentialsWithSuccessBlock:^(NSString *username) {

       NSLog(@"Login Successful");
       self.replyTextField.enabled = YES;

}


errorBlock:^(NSError *error){

       UIAlertView *alertView = [[UIAlertView alloc]
                                  initWithTitle:@"Sorry"
                                  message:@"You can't send a tweet right now, make sure your device has an internet connection and you have at least one Twitter account setup"
                                  delegate:self
                                  cancelButtonTitle:@"OK"
                                  otherButtonTitles:nil];
       [alertView show];
    }];

这是我发布回复的代码

NSLog(@"the text content%@",self.replyTextField.text);
    [self.replyTextField resignFirstResponder];
    if (self.replyTextField.text.length>0 && self.replyTextField.text.length <=140) {
        // Post reply
        [twitterWithReply postStatusUpdate:self.replyTextField.text inReplyToStatusID:self.tweeetID latitude:nil longitude:nil placeID:nil displayCoordinates:nil trimUser:nil successBlock:^(NSDictionary *status) {
            [self showSuccessDialog];
        } errorBlock:^(NSError *error) {
            NSLog(@"%@",[error localizedDescription]);
        }];

    }

目前它的作用是发布到我自己的时间轴而不回复特定的推文。我的印象是我的身份验证代码错误。那我该怎么认证?

1 个答案:

答案 0 :(得分:1)

我刚刚使用STTwitter的开发版本检查了这个场景,它按预期工作。

如果此代码不适合您,请尽可能详细地提供fill an issue

self.twitter = [STTwitterAPI twitterAPIOSWithFirstAccount];

[_twitter verifyCredentialsWithSuccessBlock:^(NSString *username) {

    [_twitter postStatusUpdate:@"test1" inReplyToStatusID:nil latitude:nil longitude:nil placeID:nil displayCoordinates:nil trimUser:nil successBlock:^(NSDictionary *status) {

        NSLog(@"-- status1: %@", status);

        [_twitter postStatusUpdate:@"test2" inReplyToStatusID:[status valueForKey:@"id_str"] latitude:nil longitude:nil placeID:nil displayCoordinates:nil trimUser:nil successBlock:^(NSDictionary *status) {
            NSLog(@"-- status2: %@", status);
        } errorBlock:^(NSError *error) {
            NSLog(@"-- error2: %@", error);
        }];

    } errorBlock:^(NSError *error) {
        NSLog(@"-- error1: %@", error);
    }];

} errorBlock:^(NSError *error) {
    NSLog(@"-- error0: %@", error);
}];

enter image description here