如何将Twitter支持集成到iOS应用程序中?

时间:2010-11-24 09:30:31

标签: xcode

如何将Twitter支持集成到iOS应用程序中?

2 个答案:

答案 0 :(得分:3)

Stefan Arentz's Twitter library很乐意使用 - 它包含您需要的视图,基本上没有编码可做。使用twitter尽早register your app获取提交请求xAuth身份验证权限,这样您就不必使用笨拙的基于Web的oAuth方法。使用xAuth,只需提交用户名和密码,并保留返回的身份验证令牌即可提交推文。

答案 1 :(得分:0)

以下是一个例子:

从您的IBAction致电-(void)sendTweet

// Sending tweets from within the application
-(void)sendTweet {
    // check if device capable of sending tweets
    if([TWTweetComposeViewControllercanSendTweet])
    {
        TWTweetComposeViewController *tweetSheet = [[TWTweetComposeViewControlleralloc] init];
        [tweetSheet setInitialText:@"Twitting from my iSecret App"];

        self.imageString = @"theSecret.png";

        if(self.imageString) {
            [tweetSheet addImage:[UIImageimageNamed:self.imageString]];
        }

        [selfpresentModalViewController:tweetSheet animated:YES];
    }
    else {
        UIAlertView *alert = [[UIAlertViewalloc]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:selfcancelButtonTitle:@"Ok"otherButtonTitles:nil];
        [alert show];
    }
}