我知道您可以在推文中放置最多四张图片,所以我想知道这是否可行,可能使用STTwitter 我知道您可以在STTwitter中使用此方法上传一个图像,但据我所知,此方法不支持多个图像:
- (NSObject<STTwitterRequestProtocol> *)postMediaUpload:(NSURL *)mediaURL
uploadProgressBlock:(void(^)(NSInteger bytesWritten, NSInteger totalBytesWritten, NSInteger totalBytesExpectedToWrite))uploadProgressBlock
successBlock:(void(^)(NSDictionary *imageDictionary, NSString *mediaID, NSString *size))successBlock
errorBlock:(void(^)(NSError *error))errorBlock
值得一提的是我正在使用Objective-C
将其构建到iOS应用程序中答案 0 :(得分:2)
1)发布媒体并存储他们的ID,如POST media/upload
中所述for(NSString *filename in @[@"1.png", @"2.png", @"3.png", @"4.png"]) {
NSString *filePath = [[@"~/Desktop/" stringByExpandingTildeInPath] stringByAppendingPathComponent:filename];
NSURL *fileURL = [NSURL fileURLWithPath:filePath];
[_twitter postMediaUpload:fileURL
uploadProgressBlock:^(NSInteger bytesWritten, NSInteger totalBytesWritten, NSInteger totalBytesExpectedToWrite) {
NSLog(@"..");
} successBlock:^(NSDictionary *imageDictionary, NSString *mediaID, NSString *size) {
NSLog(@"-- %@", mediaID);
} errorBlock:^(NSError *error) {
NSLog(@"-- %@", [error localizedDescription]);
}];
}
2)发布状态并填写mediaID,如POST statuses/update
中所述[_twitter postStatusUpdate:@"hello"
inReplyToStatusID:nil
mediaIDs:@[@"620502730948218882", @"620502730948239360", @"620502731610984448", @"620502731623534592"]
latitude:nil
longitude:nil
placeID:nil
displayCoordinates:nil
trimUser:nil
successBlock:^(NSDictionary *status) {
NSLog(@"-- %@", status);
} errorBlock:^(NSError *error) {
NSLog(@"-- %@", [error localizedDescription]);
}];
3)没有第三步: - )