我在STTwitter工作,我有一个如下问题

时间:2014-12-03 05:37:57

标签: ios7

我正在尝试以这种方式在shareTW方法中不进入成功阻止并得到像“错误创建状态”这样的错误我跟着一些教程但不幸的是他们很无奈

- (IBAction为)Btn_TwitterImgButton:(ID)发送方

{

UIImageView *tweetimage=[[UIImageView alloc]init];
if (isTwitter == NO)
{
    tweetimage.image=[UIImage imageNamed:@"twitter_on.png"];
    [self postTWDetails];
}
else if (isTwitter==YES)
{
    twitterString = @"";
    isTwitter = NO;
    tweetimage.image=[UIImage imageNamed:@"twiter@2x.png"];
}

}

-(IBAction)Tweet Button:(id)sender

{

if ([twitterString isEqualToString:@"twitter loggedin"])
{

    STTwitterAPI *twitter = [STTwitterAPI twitterAPIOSWithFirstAccount];

    [twitter verifyCredentialsWithSuccessBlock:^(NSString *username)
     {
         //   [self postTWDetails];
     }
                                    errorBlock:^(NSError *error)
     {
         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Twitter Accounts" message:@"There are no Twitter accounts configured. You can add a Twitter account in your phone's Settings." delegate:self                                                       cancelButtonTitle:@"Ok"  otherButtonTitles:nil];
         [alert show];
     }];

    [self sharetoTW];
}}

- (无效)postTWDetails {     twitterString = @“twitter loggedin”;

isTwitter = YES;

}

- (无效)sharetoTW {

NSString * Str = [self.tweetTextView text]; NSLog(@“str%@”,Str);

NSLog(@"tweetTextView text %@",self.tweetTextView.text);
STTwitterAPI *twitter = [STTwitterAPI twitterAPIOSWithFirstAccount];

[twitter verifyCredentialsWithSuccessBlock:^(NSString *username)
 {
    [twitter postStatusUpdate:Str inReplyToStatusID:nil mediaURL:[NSURL URLWithString:@"https://www.google.com"] placeID:nil latitude:nil longitude:nil successBlock:^(NSDictionary *status)
      {
          NSLog(@"Success block");
      }
                    errorBlock:^(NSError *error)
      {
          NSLog(@"str %@",Str);
          NSLog(@"error ====%@",[error localizedDescription]);
      }];

 }
                                errorBlock:^(NSError *error)
 {
     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Twitter Accounts" message:@"There are no Twitter accounts configured. You can add a Twitter account in your phone's Settings." delegate:self                                                       cancelButtonTitle:@"Ok"  otherButtonTitles:nil];
     [alert show];

 }];

}

1 个答案:

答案 0 :(得分:2)

我刚刚改变了post方法 - (void)sharetoTW AND WORKING FINE .. !!

-(void)sharetoTW
{

NSString *Str=[self.placeholdertextview text];
NSLog(@"str %@",Str);

NSLog(@"placeholder text %@",self.placeholdertextview.text);
STTwitterAPI *twitter = [STTwitterAPI twitterAPIOSWithFirstAccount];
     dispatch_async(dispatch_get_main_queue(), ^{
    [twitter verifyCredentialsWithSuccessBlock:^(NSString *username)
     {
         [twitter postStatusUpdate:Str
                 inReplyToStatusID:nil
                          latitude:nil
                         longitude:nil
                           placeID:nil
                displayCoordinates:nil
                          trimUser:nil
                      successBlock:^(NSDictionary *status)
         {
             NSLog(@"Success Block");
         }
            errorBlock:^(NSError *error)
          {
              NSLog(@"error ====%@",[error localizedDescription]);

        }];


     }
         errorBlock:^(NSError *error)
     {
         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Twitter Accounts" message:@"There are no Twitter accounts configured. You can add a Twitter account in your phone's Settings." delegate:self                                                       cancelButtonTitle:@"Ok"  otherButtonTitles:nil];
         [alert show];

     }];

});

}