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 .
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.