【问题标题】:iOS TumblrSDK post photo issueiOS TumblrSDK 发布照片问题
【发布时间】:2015-09-16 13:26:50
【问题描述】:

我正在开发一个本地 iOS 应用程序,我需要在其中发布到 Tumblr。

我找到了官方的 TumblrSDK (https://github.com/tumblr/TMTumblrSDK) 并决定使用它。

现在我正在测试这个 SDK,我遇到了一个问题,我可以从我的模拟器(使用 postPhotoExample 项目)将照片发布到 Tumblr,但是从我的真实 iOS 设备执行完全相同的代码会返回一个错误代码(400 - 错误请求 - 上传照片错误)

我正在运行 TumblrSDK 示例项目 (postPhoto) 中的以下代码

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"blue" ofType:@"png"];
[[TMAPIClient sharedInstance] photo:@"blogName"
                      filePathArray:@[filePath]
                   contentTypeArray:@[@"image/png"]
                      fileNameArray:@[@"blue.png"]
                         parameters:@{@"caption" : @"Test"}
                           callback:^(id response, NSError *error) {
                               if (error)
                                   NSLog(@"Error posting to Tumblr");
                               else
                                   NSLog(@"Posted to Tumblr");
                           }];

我知道 iOS 设备区分大小写而模拟器不区分大小写,但我发送的请求在我发送的每个帖子上看起来都完全相同。

有人遇到过类似的问题吗?

【问题讨论】:

    标签: ios objective-c tumblr


    【解决方案1】:

    你的代码之前有这个吗?

      // Authenticate via OAuth
    [TMAPIClient sharedInstance].OAuthConsumerKey = @"your key";
    [TMAPIClient sharedInstance].OAuthConsumerSecret = @"your secret";
    [TMAPIClient sharedInstance].OAuthToken = @"your token";
    [TMAPIClient sharedInstance].OAuthTokenSecret = @"your token secret";
    

    如果没有,请转到 here 并注册您的 Tumblr 应用程序,然后您将获得所需的所有密钥。只需将它们复制粘贴到代码的上部,然后将它们放在您的应用程序中,然后再发布照片的代码。希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 2011-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-30
      • 1970-01-01
      • 1970-01-01
      • 2012-06-06
      • 2020-12-20
      相关资源
      最近更新 更多