Rot*_*ten 7 iphone twitter objective-c ios5
有没有办法使用TWRequest或类似的东西将照片添加到Twitter时间线?在这种情况下,我非常迷失.
我可以使用TWRequest for iOS5和MGTwitterEngine为以前的iOS版本发布状态更新,但是我无法将UIImage附加到更新.
提前感谢您提供的任何帮助.
小智 15
我在这个网站上发现并使用了很多很棒的答案,谢谢大家,认为现在是时候回馈:)详细说明诺亚的回答,这是最终的代码,对我来说,使用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];
}];
Run Code Online (Sandbox Code Playgroud)
我发现使用TWRequest是我的场景的最佳解决方案,因为我不希望用户能够在发布之前编辑帖子(这是使用TWTweetComposeViewController的问题)