2015-04-01 3194 views
2

我使用Twitter的SDK来登录和鸣叫。认证它没问题,但是当使用TWTRComposer和简单文本时,SDK回调返回'TWTRComposerResultDone',但模拟器/设备显示'tweet“文本”无法发送,因为连接到Twitter失败。 调试器显示'plugin com.apple.share.Twitter.post invalidated',但一切都是正确的。使用Twitter SDK发送推文失败,但我不知道为什么

有没有错误或我忘了一些东西。

我的代码:

TWTRComposer *作曲家= [[TWTRComposer的alloc] INIT];

[composer setText:@“some text”];

[作曲家showWithCompletion:^(TWTRComposerResult结果){ 如果(结果== TWTRComposerResultCancelled){ 的NSLog(@ “资料Tweet组合物取消”); } 其他{ NSLog(@“Send Tweet!”); } }];

回答

0

下面资料Tweet像TwitterCore.framework,TwitterKit.framework,Fabric.framework twitter.developer
2.附加的Twitter框架使用SDK

1. Crearte应用,TwitterKitResources.bundle
3.写推特按钮中的代码

[[Twitter sharedInstance] startWithConsumerKey:@"YourConsumerKey" consumerSecret:@"YourConsumerSecret"]; 
    [Fabric with:@[[Twitter sharedInstance]]]; 

    [[Twitter sharedInstance] logInWithCompletion:^(TWTRSession *session, NSError *error) 
    { 
    if (session) 
    { 
     NSLog(@"logged in user with id %@", session.userID); 

     TWTRComposer *composer = [[TWTRComposer alloc] init]; 
     [composer setText:@"Enter Your Tweet Message"]; 
     //[composer setImage:[UIImage imageNamed:@"fabric"]]; 
     [composer showFromViewController:self completion:^(TWTRComposerResult result) { 
      if (result == TWTRComposerResultCancelled) 
      { 
       NSLog(@"Tweet composition cancelled"); 
      } 
      else 
      { 
       NSLog(@"Sending Tweet!"); 
       UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:@"" message:@"Sent Tweet!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
       [warningAlert show]; 
      } 
     }]; 

    } 
    else 
    { 
     // log error 
    } 
}]; 
相关问题