简体   繁体   English

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

[英]Upload Multiple Photos to Twitter Using STTwitter

I know that you can put up to four images in a tweet, so I was wondering if that was possible, possibly using STTwitter I know that you can upload one image using this method in STTwitter, but as far as I know this method doesn't support multiple images: 我知道您最多可以在一条推文中放置四个图像,所以我想知道是否可能,可能使用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

Worth mentioning I'm building this into an iOS app using Objective-C 值得一提的是,我正在使用Objective-C将其构建到iOS应用中

1) post medias and store their IDs, as documented in POST media/upload 1)发布媒体并存储其ID,如POST媒体/上传中所述

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 status and fill mediaIDs, as documented in POST statuses/update 2)发布状态和填写mediaID,如POST状态/更新中所述

[_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) there's no step three :-) 3)没有第三步:-)

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM