首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用STTwitter将多张照片上传到推特

使用STTwitter将多张照片上传到推特
EN

Stack Overflow用户
提问于 2015-07-12 14:40:18
回答 1查看 633关注 0票数 0

我知道您可以在一条推特中最多上传四个图像,所以我想知道这是否可能,可能使用STTwitter,我知道您可以在STTwitter中使用此方法上传一个图像,但据我所知,该方法不支持多个图像:

代码语言:javascript
复制
- (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构建一个iOS应用程序。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-13 08:05:18

1)发布媒体并存储它们的ID,如后媒体/上载中所记录的

代码语言:javascript
复制
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)发布状态和填充媒体in,如员额状态/更新中所记录的

代码语言:javascript
复制
[_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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31368963

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档