0

I am trying to integrate Tumblr into my app for simply posting of pics into tumblr.

I am confused in following the authentication process of tumblr.

I registered the app.

I have the consumer key, and the consumer secret key.

I have requested for the token and the token secret key by using OAuthConsumer.

However I am failing to do the next step which is posting a photo .

This is the code I'm using to authenticate:

     [[TMAPIClient sharedInstance]authenticate:@"myappURLScheme" callback:^(NSError *err) {

        NSLog(@"authentication failed %@",err);
    }];

And this takes me to the safari tumblr page, to do the Allow/ Not allow process.After I click on Allow, it takes me to the tumblr app. But the pic is not posted.

Here is what I tried to post the pic:

[[TMAPIClient sharedInstance] photo:@"Sample Upload"
                      filePathArray:@[[_imagesPath stringByAppendingPathComponent:
                                       @"tm.png" ]]
                   contentTypeArray:@[@"image/png"]
                      fileNameArray:@[@"tm.png"]
                         parameters:@{@"caption" : @"Caption"}
                           callback:^(id response, NSError *error) {
                               if (error)
                                   NSLog(@"Error posting to Tumblr %@",error);
                               else
                                   NSLog(@"Posted to Tumblr %@",error);
                           }];

HEre I get the error:

  Error posting to Tumblr Error Domain=Request failed Code=404 "(null)"

The response parameter is also null.

I believe the authentication is a success,I am also able to get the user info from the Tumblr. but I'm not sure why the pic is not posted .

Teja Nandamuri
  • 11,045
  • 6
  • 57
  • 109

1 Answers1

1

Is Sample Upload your blog? I have to admit Tumblr's naming conventions are really bad, but if you check the code, you can see you need to pass the blog name there.

- (void)photo:(NSString *)blogName filePathArray:(NSArray *)filePathArrayOrNil contentTypeArray:(NSArray *)contentTypeArrayOrNil
fileNameArray:(NSArray *)fileNameArrayOrNil parameters:(NSDictionary *)parameters callback:(TMAPICallback)callback;

Otherwise make sure you set the OAuthConsumerKey, OAuthConsumerSecret, OAuthToken and OAuthTokenSecret before sending the request.

Your code looks fine otherwise, about the same worked for me.

floschliep
  • 513
  • 5
  • 14
  • what shall we send to filePAthArray ? path to the image ? or path to the folder that contains image ? – Teja Nandamuri Jan 21 '16 at 15:53
  • Thanks for the answer. One more question. By this method, it simply posts the photo to tumblr. Doesnt the API let the app to go to tumblr and let the user post it just like the facebook post API ? – Teja Nandamuri Jan 21 '16 at 15:55
  • 1
    filePathArray must be an array of file paths (`NSString`s). – floschliep Jan 21 '16 at 15:56
  • 1
    No, the SDK just provides the API to post to Tumblr. You need to build an interface for that on your own. – floschliep Jan 21 '16 at 15:58