有没有办法使用 TWRequest 或类似的东西将照片添加到 Twitter 时间轴?在这种情况下我非常迷茫。
我可以使用适用于 iOS5 的 TWRequest 和适用于以前 iOS 版本的 MGTwitterEngine 发布状态更新,但我无法将 UIImage 附加到更新。
在此先感谢您提供的任何帮助。
最佳答案
我在这个网站上找到并使用了很多很棒的答案,谢谢大家,我想是时候回馈了 :) 详细说明 Noah 的答案,这是我在使用 TWRequest 发送推文...
TWRequest *postRequest = [[TWRequest alloc] initWithURL:[NSURL URLWithString:@"https://upload.twitter.com/1/statuses/update_with_media.json"] parameters:nil requestMethod:TWRequestMethodPOST];
UIImage * image = [UIImage imageNamed:@"myImage.png"];
//add text
[postRequest addMultiPartData:[@"I just found the secret level!" dataUsingEncoding:NSUTF8StringEncoding] withName:@"status" type:@"multipart/form-data"];
//add image
[postRequest addMultiPartData:UIImagePNGRepresentation(image) withName:@"media" type:@"multipart/form-data"];
// Set the account used to post the tweet.
[postRequest setAccount:twitterAccount];
// Perform the request created above and create a handler block to handle the response.
[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];
}];
我发现使用 TWRequest 是我的场景的最佳解决方案,因为我不希望用户能够在发推之前编辑帖子(这是使用 TWTweetComposeViewController 的问题)
关于iphone - iOS 5 使用 Twitter API 将照片附加到 Twitter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8129079/