这是我用来将图片发布到twitter的代码块。
NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"info" ofType:@"png"];
UIImage *image = [[UIImage alloc] initWithContentsOfFile:imagePath];
NSData *imageData = UIImageJPEGRepresentation(image,.05);
[_twitter postMediaUploadData:imageData fileName:@"splash_02" uploadProgressBlock:^(NSInteger bytesWritten, NSInteger totalBytesWritten, NSInteger totalBytesExpectedToWrite) {
} successBlock:^(NSDictionary *imageDictionary, NSString *mediaID, NSString *size) {
NSLog(@"xfdf=%@",imageDictionary);
} errorBlock:^(NSError *error) {
NSLog(@"xfdferror=%@",error);
}];我得到了成功的响应,但没有发布图片
发布于 2014-09-16 16:09:16
正如推特的documentation中解释的那样,这个方法确实会发布图像并返回一个mediaID,然后可以在tweet中使用。当您想要发布多张图片并在将来的推文中使用它们时,请使用此方法。
如果您想在一行中同时发布图像和推文,请参阅POST statuses/update_with_media端点的STTwitter's methods。
https://stackoverflow.com/questions/25848818
复制相似问题