Closed ashishguru1986 closed 11 years ago
photo:@"Test" here you can fill you blog name ex: my blog :http://.www.sevenloveit.tumblr.com blog name : seventloveit
But if i dont know the blog name then how can i directly post to tumblr so that i can see it under post section on my home page ?
Even i created a blog at tumblr and passed the same in photo:@"My Test Blog" , i am getting "Error posting to Tumblr".
I am guessing that you are not passing the blog name correctly. "My Test Blog" is not a valid blog name, as blog names cannot have spaces in them.
This is an example of how to post a photo. As far as I can tell you are doing everything right except passing a blog name. You can get the user's list of blogs by making a userInfo
request.
yes i was not passing a valid blog name. My requirement is to post directly on user dashboard from the app. To achieve this i must pass a valid blog name as per api method. But suppose i want to post a photo on dashboard then but i need to do. Is there any method to create a blog so that after blog is created i can post the photo or any method to directly post image on user dashboard ? Hope you are getting my requirement !!!
Mine still doesnt post
[[TMAPIClient sharedInstance] photo:@"sankaet" filePathArray:@[post[@"gif"]] contentTypeArray:@[@"image/gif"] parameters:@{@"caption" : [NSString stringWithFormat:@"test post by %@",post[@"user_fullname"]]} callback:^(id response, NSError *error) { if (error) NSLog(@"Error posting to Tumblr"); else NSLog(@"Posted to Tumblr"); }];
The error is
Error Domain=Request failed Code=400 "The operation couldn’t be completed. (Request failed error 400.)"
response { errors = ( "Error uploading photo." ); }
I guess the problem might be error uploading a photo that isn't on the device itself. does it have to be?
My requirement is to post directly on user dashboard from the app
Sorry, I am not getting your requirement. The dashboard is not something that can be posted to. Blogs have posts and if you follow a blog, its posts show up on your dashboard. You always need to be posting to a blog name that the currently authenticated user owns.
I guess the problem might be error uploading a photo that isn't on the device itself. does it have to be?
Yes. The filePathArray
must contain local files that your application can read off disk and upload to the API.
would a Cached NSData work?
No, sorry. Only paths to files on disk for now.
I am trying to save the data on disk before I upload even that doesnt seem to work
NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSCachesDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:nil];
NSURL *fileURL = [documentsDirectoryURL URLByAppendingPathComponent:@"tumblr.gif"];
[object writeToFile:[fileURL absoluteString] options:NSDataWritingAtomic error:nil];
[[TMAPIClient sharedInstance] photo:@"sankaet" filePathArray:@[[fileURL absoluteString]] contentTypeArray:@[@"image/gif"] parameters:@{@"caption" : [NSString stringWithFormat:@"%@'s test post",post[@"user_fullname"]], @"link": post[@"shortened_link"]} callback:^(id response, NSError *error) {
if (error)
NSLog(@"Error posting to Tumblr %@ and response %@",error,response);
else
NSLog(@"Posted to Tumblr");
}];
Am I doing something wrong?
There could be any number of things going wrong. Use an HTTP proxy to ensure you're actually sending image data across the wire. It could be that the GIF you're trying to post is too big (a common problem), feel free to use the image from this fully functioning photo posting example to rule out a problem with your particular GIF.
I tried
[[TMAPIClient sharedInstance] photo:@"sankaet" filePathArray:@[[[NSBundle mainBundle] pathForResource:@"userDefaultPicture" ofType:@"png"]] contentTypeArray:@[@"image/png"] parameters:@{@"caption" : [NSString stringWithFormat:@"%@'s post",post[@"user_fullname"]], @"link": post[@"shortened_link"]} callback:^(id response, NSError *error) {
if (error)
NSLog(@"Error posting to Tumblr %@ and response %@",error,response);
else
NSLog(@"Posted to Tumblr");
}];
even then it gives me an error
Error posting to Tumblr Error Domain=Request failed Code=400 "The operation couldn’t be completed. (Request failed error 400.)" and response { errors = ( "Error uploading photo." ); }
and when I use my GIFs it gives me the following error
JXHTTPMultipartBody.m (78) ERROR: The operation couldn’t be completed. (Cocoa error 260.) Error posting to Tumblr Error Domain=Request failed Code=400 "The operation couldn’t be completed. (Request failed error 400.)" and response { errors = ( "Error uploading photo." ); }
Did you read my last comment? Did you verify that you're actually sending multipart data up to the server using an HTTP proxy? Did you try using the image in the fully working example I linked to? Seriously look at the raw HTTP requests made by the sample program and yours, using the same image file, and see what the difference is. This isn't an SDK issue at this point, you're running into some problem with the API. I'm guessing it's because your file either A) doesn't exist or B) is too large, as I previously stated. I don't know what else to tell you.
Hi irace, suppose i am a new user on Tumblr and not following any blog. So how i can post a image using Tumblr API for iOS ?
This is a general Tumblr question, and not really related to the Tumblr SDK. How many blogs a user is following has nothing do with posting. You post to your blog, not someone else's. Every user has at least one blog; their primary blog's name is the same as their username.
I'd suggest reading through our help documents to get a better understanding of how Tumblr works: http://www.tumblr.com/help
"Did you verify that you're actually sending multipart data up to the server using an HTTP proxy?" I am not sure how to do that. I did try to run the PhotoPostExample, that works just fine. Then I used the same code and the same image in my app and its still giving me the same error. I am not sure why
also, the text posts work just fine, but still it doesn't show which app the post was made by (as it usually shows in the right hand corner), am I missing something?
No, only a few select applications are currently whitelisted for attribution.
Is the multipart method of posting photo still supported by the API. I could not get it to work. Finally, got it working by going down to the lower level method
TMAPIClient *client = [TMAPIClient sharedInstance];
NSDictionary *parameters = @{@"source": @"http://upload.wikimedia.org/wikipedia/en/d/d5/Snowcrash.jpg"};
[client post:blog type:@"photo" parameters:parameters
callback:^(id response, NSError *error) {
if (error) {
NSLog(@"Error posting to Tumblr");
} else {
}
}];
It's still there, can I see a code sample that wasn't working?
The following did not work for me. I double checked that the image does exist in the bundle and that I can post text postings with the same credentials.
[[TMAPIClient sharedInstance] photo:blog
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");
else
NSLog(@"Posted to Tumblr");
}];
I too am having difficulty posting a photo using the Photo example project. The error message is not helpful at all. Given that it's an example project the onboarding should be cleaner than this.
Same issue here. I copied the blue.png into my project, successfully completed authentication, checked my blog name with userInfo, but still cannot get the picture posted.
Error Domain=Request failed Code=400 "The operation couldn’t be completed. (Request failed error 400.)
[TMAPIClient sharedInstance].OAuthConsumerKey = k_TUMBLR_CONSM_KEY;
[TMAPIClient sharedInstance].OAuthConsumerSecret = k_TUMBLR_SECRET_KEY;
[[TMAPIClient sharedInstance] authenticate:@"myapp://tumblr-authorize" callback:^(NSError *error) {
}];
I am trying to post image after authentication, i am able to authenticate using above code but not able to post image after success full authentication. I am getting @"Error posting to Tumblr". I did some debugging and getting request callback JSON below:
(NSDictionary *) $1 = 0x0715df70 { meta = { msg = "Not Authorized"; status = 401; }; response = ( ); }
Please guide me what i am missing ?