我使用AddThis SDK
用于Facebook,Twitter和电子邮件分享,Facebook和电子邮件很好地工作,而Twitter在从我的Iphone进行连接时出错。
我的模拟器很棒,但iphone twitter没有连接,只是在控制台中显示一条消息"Error!"
代码:
[AddThisSDK setTwitterViaText:@"QuotesApp"];
[AddThisSDK shareURL:@"http://HazratAliQuotes.com"
withService:@"twitter" title:string description:@"QuotesApp"];
答案 0 :(得分:0)
这是您的可选答案。在 IOS 5中有框架Tweeter.Framework。添加此框架并导入,我使用它来上传图像(作为链接)和消息。可能对你有帮助。:)
并点击按钮点击..
- (void)postImageOnTweeterWall
{
if (imageView.image)
{
NSLog(@"tweetbutton pressed called");
// Create the view controller
TWTweetComposeViewController *twitter = [[TWTweetComposeViewController alloc] init];
// Optional: set an image, url and initial text
[twitter addImage:[UIImage imageNamed:@"img1.jpeg"]];
// [twitter addURL:[NSURL URLWithString:[NSString stringWithString:@"http://MobileDeveloperTips.com/"]]];
[twitter setInitialText:@"Tweet from iOS 5 app using the Twitter framework."];
// Show the controller
[self presentModalViewController:twitter animated:YES];
// Called when the tweet dialog has been closed
twitter.completionHandler = ^(TWTweetComposeViewControllerResult result)
{
NSString *title = @"Tweet Status";
NSString *msg;
if (result == TWTweetComposeViewControllerResultCancelled)
msg = @"Tweet compostion was canceled.";
else if (result == TWTweetComposeViewControllerResultDone)
msg = @"Tweet composition completed.";
// Show alert to see how things went...
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
[alertView show];
// Dismiss the controller
[self dismissModalViewControllerAnimated:YES];
};
}
else
{ UIAlertView *alertView = [[[UIAlertView alloc] initWithTitle:@"Tweeter" message:@"Select photo to Upload"
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease];
[alertView show];
}
}
答案 1 :(得分:0)
尝试使用此link在您的应用程序中为以前版本的iOS
实现TwitterTwitter的Previos API称为MGTTwitter
对于AddThis:
要使用支持Twitter OAuth的共享,您需要告知磁带库这样做,然后配置您的Twitter使用者密钥,使用者密钥和回调URL。
[AddThisSDK setTwitterAuthenticationMode:ATTwitterAuthenticationTypeOAuth];
[AddThisSDK setTwitterConsumerKey:@"yourconsumerkey"];
[AddThisSDK setTwitterConsumerSecret:@"yourconsumersecret"];
[AddThisSDK setTwitterCallBackURL:@"yourcallbackurl"];
以下是新增的答案。
删除第[AddThisSDK setTwitterViaText:@"QuotesApp"];
行
添加第[AddThisSDK setTwitterAuthenticationMode:ATTwitterAuthenticationTypeOAuth];
行
并按下twitter按钮创建一个选择器并将以下代码添加为
[AddThisSDK shareURL:@"http://www.addthis.com"
withService:@"twitter"
title:@"AddThis - The #1 Bookmarking & Sharing Service"
description:@"AddThis is a free way to boost traffic back to your site by making it easier for visitors to share your content."];