无法使用 Tumblr SDK 示例发布照片 [英] Unable to post a photo using the Tumblr SDK example

查看:30
本文介绍了无法使用 Tumblr SDK 示例发布照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用示例上传照片:Tumblr 给出的 PhotoPostExample (https://github.com/tumblr/TMTumblrSDK)

I'm trying to upload a photo using the example: PhotoPostExample given by Tumblr (https://github.com/tumblr/TMTumblrSDK)

我似乎无法上传照片.我已经可以发布文本帖子并查看用户信息,所以我认为该应用程序已经过身份验证.我已经检查过 NS Bundle 中提到的照片是否存在,并且确实存在.我什至缩小了照片以使其文件更小,但仍然无法上传.

I can't seem to upload a photo. I can already post a text post and view the user info, so I think the app is already authenticated. I've already checked if the photo referred to in the NS Bundle exists, and it does. I've even reduced the photo to make it smaller in file size and still it won't upload.

它显示这个错误:

错误域=请求失败代码=401操作不能完全的.(请求失败错误 401.)"

Error Domain=Request failed Code=401 "The operation couldn’t be completed. (Request failed error 401.)"

这是我使用的 Tumblr 提供的 postphoto 中的代码:

Here's the code inside postphoto given by Tumblr that I used:

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

非常感谢您的帮助!- 误收

Your help is very much appreciated! - Misheal

推荐答案

您正在查看回调中的error"参数,这很好.

You're looking at the "error" parameter in your callback, that's good.

但是,如果您想要更多有用的细节,请解析 JSON response,您最终可能会看到如下内容:

But if you want even more useful detail, parse the JSON response and you might end up getting to see something like:

(NSDictionary *) $1 = 0x0715df70 {
    meta = {
       msg = "Not Authorized";
       status = 401;
    };
response = ( );
}

我怀疑您的身份验证并不像您认为的那样.

I suspect you are not as authenticated as you think you were.

这篇关于无法使用 Tumblr SDK 示例发布照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆