使用 STTwitter 将多张照片上传到 Twitter

Upload Multiple Photos to Twitter Using STTwitter

我知道一条推文最多可以放四张图片,所以我想知道这是否可行,可能使用 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 应用程序中

1) post 媒体并存储它们的 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) post 状态并填写 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) 没有第三步:-)

https://twitter.com/nst022/status/620503183564107776