Objective c 如何在ios5中通过iphone在twitter上发送图像
我想使用twitter api twitter+OAuth在twitter上分享iphone上的图像,但我不知道如何从iphone上分享。我用sharekit尝试过同样的操作,但没有成功。您能告诉我如何使用twitter api在iphone的twitter上共享图像吗?使用Sharekit共享图像 教程:您是否查看了以下内容: 这只适用于带有iOS5的手机 在iOS5之前的应用程序中,我使用TwitPic上传照片并发布Twitter状态。这里有一个关于如何使用AshtPrequest进行Twitter状态更新的很好的教程:Objective c 如何在ios5中通过iphone在twitter上发送图像,objective-c,xcode,ios4,Objective C,Xcode,Ios4,我想使用twitter api twitter+OAuth在twitter上分享iphone上的图像,但我不知道如何从iphone上分享。我用sharekit尝试过同样的操作,但没有成功。您能告诉我如何使用twitter api在iphone的twitter上共享图像吗?使用Sharekit共享图像 教程:您是否查看了以下内容: 这只适用于带有iOS5的手机 在iOS5之前的应用程序中,我使用TwitPic上传照片并发布Twitter状态。这里有一个关于如何使用AshtPrequest进行Twi
如果你想采用这种方法,请告诉我,除了本教程之外,你还需要做其他工作,你还需要从TwitPic获得API密钥。zot提供的链接有效,但我必须添加一些代码,另外我还必须添加两个框架Twitter.framework和Account.framework。修改后的代码如下所示
- (IBAction)sendCustomTweet:(id)sender {
// Create an account store object.
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
// Create an account type that ensures Twitter accounts are retrieved.
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
// Request access from the user to use their Twitter accounts.
[accountStore requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error) {
if(granted) {
// Get the list of Twitter accounts.
NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];
if ([accountsArray count] > 0) {
// Grab the initial Twitter account to tweet from.
ACAccount *twitterAccount = [accountsArray objectAtIndex:0];
UIImage *image =[UIImage imageNamed:@"Icon.png"];
TWRequest *postRequest = [[TWRequest alloc] initWithURL:[NSURL URLWithString:@"https://upload.twitter.com/1/statuses/update_with_media.json"]
parameters:[NSDictionary dictionaryWithObject:@"Hello. This is a tweet." forKey:@"status"] requestMethod:TWRequestMethodPOST];
// "http://api.twitter.com/1/statuses/update.json"
[postRequest addMultiPartData:UIImagePNGRepresentation(image) withName:@"media" type:@"multipart/png"];
// Set the account used to post the tweet.
[postRequest setAccount:twitterAccount];
[postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSString *output = [NSString stringWithFormat:@"HTTP response status: %i", [urlResponse statusCode]];
[self performSelectorOnMainThread:@selector(displayText:) withObject:output waitUntilDone:NO];
}];
}
}
}];
}
你只是想在twitter上共享你的图片链接,还是想先上传图片,然后获取图片链接,然后再上传到twitter上。我想在twitter上发布图片