首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我在STTwitter上工作,我有一个问题如下

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

Stack Overflow用户
提问于 2014-12-03 05:37:57
回答 1查看 58关注 0票数 1

我正以这种方式尝试,它不会进入shareTW方法中的成功块,并且得到一个类似于“错误创建状态”的错误--我遵循了一些教程,但不幸的是,它们是无助的。

-(IBAction)Btn_TwitterImgButton:(Id)发件人

{

代码语言:javascript
复制
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"];
}

}

代码语言:javascript
复制
-(IBAction)Tweet Button:(id)sender

{

代码语言:javascript
复制
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";

代码语言:javascript
复制
isTwitter = YES;

}

-(void)sharetoTW {

NSString *Str=self.tweetTextView text;NSLog(@Str%@,Str);

代码语言:javascript
复制
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];

 }];

}

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-12-03 06:36:34

我刚刚在-(无效)sharetoTW中更改了post方法,并且工作很好..!

代码语言:javascript
复制
-(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];

     }];

});

}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27264423

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档