Unable to post a photo using the Tumblr SDK example

邮差的信 提交于 2020-01-06 15:16:23

问题


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

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.

It shows this error:

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

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


回答1:


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

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.



来源:https://stackoverflow.com/questions/21049624/unable-to-post-a-photo-using-the-tumblr-sdk-example

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!