error uploading photo : tumblr api ios - ios

When I try to upload a image using following code,
NSString *imagePath = [photo getAbsouluteMediaPath]; // imagePath = assets-library://asset/asset.JPG?id=F6DDD72D-5E08-4C9C-9D5C-E7382578B3FC&ext=JPG
[[TMAPIClient sharedInstance] photo:name filePathArray:#[imagePath] contentTypeArray:#[#"image/jpg"] fileNameArray:#[#"Photo.jpg"] parameters:#{#"caption" : #"test"} callback:^(id response, NSError *error) {
if (error){
NSLog(#"Error posting to Tumblr %#",error);
}
else{
NSLog(#"Posted to Tumblr");
}
}];
Im getting following error,
Error Domain=Request failed Code=400 "The operation couldn’t be completed. (Request failed error 400.)"
Please help me to find the issue!

Related

The operation couldn’t be completed. (com.google.HTTPStatus error 403.)

I am trying to download from google drive file in iOS and getting error in the following
GTLServiceDrive* googleDriveService = [[GTLServiceDrive alloc] init];
NSString *urlTest = [NSString stringWithFormat:#"https://www.googleapis.com/drive/v3/files/%#?alt=media",itemIdentifier[indexPath.row]];
GTMSessionFetcher *fetcherTest = [googleDriveService.fetcherService fetcherWithURLString:urlTest];
[fetcherTest beginFetchWithCompletionHandler:^(NSData *data, NSError *error) {
if (error == nil) {
NSLog(#"Retrieved file content");
NSLog(#"File size is : %.2f MB",(float)data.length/1024.0f/1024.0f);
// Do something with data
} else {
NSLog(#"error: %#", [error localizedDescription]);
}
}];
error: The operation couldn’t be completed. (com.google.HTTPStatus
error 403.)

downloading video from youtube objective c

I'm trying to download video from youtube but getting error.
Error mention in code
my code
-(void)downloadVideo{
LBYouTubeExtractor *extractor = [[LBYouTubeExtractor alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat:(#"https://www.youtube.com/watch?v=%#"), videoIdToDownload ]] quality:LBYouTubeVideoQualityLarge];
[extractor extractVideoURLWithCompletionBlock:^(NSURL *videoURL, NSError *error) {
if(!error) {
NSLog(#"Did extract video URL using completion block: %#", videoURL);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSError* error = nil;
NSData* data1 = [NSData dataWithContentsOfURL:videoURL options:NSDataReadingUncached error:&error]; //data1 is nill
if (error) { //Error Domain=NSCocoaErrorDomain Code=256 "The file “3gpp;+codecs="mp4v.20.3,+mp4a.40.2"&fallback_host=tc.v8.cache4.googlevideo.com&itag=36” couldn’t be opened."
NSLog(#"error=%#", error);
}else{
NSString *filename = [NSString stringWithFormat:(#"video_%#.mp4"), videoIdToDownload ];
[data1 writeToFile:[dirPath stringByAppendingPathComponent:filename] atomically:YES];
NSLog(#"File %# successfully saved", filename);
}
});
} else {
NSLog(#"Failed extracting video URL using block due to error:%#", error);
}
}];
}
using this lib
https://github.com/larcus94/LBYouTubeView
If anyone now solution please help me.
Thanks

Failed to fetch current user The operation couldn’t be completed. (NSURLErrorDomain error -1012

I'm getting NSURLErrorDomain error -1012. error in xcode 6.2 , I'm able to get the access token successfully, I tried reseting simulator.. here is the code
-(void)getLinkedInData:(LIALinkedInHttpClient*)client
{
[client getAuthorizationCode:^(NSString *code) {
[client getAccessToken:code success:^(NSDictionary *accessTokenData) {
NSLog(#"Access token data: %#",accessTokenData);
NSString *accessToken = [accessTokenData objectForKey:#"access_token"];
NSLog(#"Access token: %#",accessToken);
[client GET:[NSString stringWithFormat:#"https://api.linkedin.com/v1/people/~?oauth2_access_token=%#&format=json", accessToken] parameters:nil success:^(AFHTTPRequestOperation *operation, NSDictionary *result) {
NSLog(#"current user %#", result);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(#"failed to fetch current user %#", error.localizedDescription);
}];
} failure:^(NSError *error) {
NSLog(#"Querying accessToken failed %#", error);
}];
} cancel:^{
NSLog(#"Authorization was cancelled by user");
} failure:^(NSError *error) {
NSLog(#"Authorization failed ::::%#", error.localizedDescription);
}];
}
I'm not sure if this'll answer your question, but I've found that when a calling a web service synchronously, which returns a 401 "Not authorised" error, iOS will simply return a vague -1012 error.
iOS: How can i receive HTTP 401 instead of -1012 NSURLErrorUserCancelledAuthentication
So, try to check whether you're having authentication problems, and tackle the problem from there.

PFFacebookUtil Timeout Error

I am having similar issue as mentioned here: https://www.parse.com/questions/error-when-trying-to-reauthorise-facebook-user
When my app starts up, if the user is already logged in it tries to fetch the user's profile image from Facebook:
- (void)getFacebookIdAndProfileImageWithSuccess:(void(^)(NSDictionary *))success {
// Send request to Facebook to retrieve profile information
FBRequest *request = [FBRequest requestForMe];
[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (error)
return;
// Result is a dictionary of user information
NSMutableDictionary *userData = (NSMutableDictionary *)result;
NSString *facebookId = userData[#"id"];
[userData setObject:facebookId forKey:#"facebookId"];
// Retrieve the user profile image
NSURL *imageUrl = [NSURL URLWithString:[NSString stringWithFormat:#"%#/%#/picture?height=55&width=55", BaseApiUrl, facebookId]];
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:imageUrl]];
[userData setObject:image forKey:#"image"];
[userData setObject:[imageUrl absoluteString] forKey:#"imageUrl"];
success([NSDictionary dictionaryWithDictionary:userData]);
}];
}
Well it takes a long time for the request to return and when it does it reports an error:
"Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0x146aa790 {com.facebook.sdk:ErrorInnerErrorKey=Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo=0x146a1710 {NSErrorFailingURLStringKey=https://graph.facebook.com/,
NSErrorFailingURLKey=https://graph.facebook.com/, NSLocalizedDescription=The request timed out., NSUnderlyingError=0x1455c110 "The request timed out."}, com.facebook.sdk:HTTPStatusCode=200, com.facebook.sdk:ErrorSessionKey=<PFReceptionist: 0x14685310>}"
I deleted my app and installed it again. This resolved the issue. The problem might have been that before I started getting this error I was trying to resolve another Facebook related issue my app was having. And one of the things I tried was deleting my Facebook account Settings > Facebook. Maybe that had something to do with this error, I am not sure.
try this:
[FBSession openActiveSessionWithReadPermissions:#[#"basic_info",#"email"] allowLoginUI:YES completionHandler:^(FBSession *session,FBSessionState status,NSError *error){
if(error)
{
[self hideLoadingMode];
NSLog(#"Facebook Error : %#",error.localizedDescription);
// end you can use every thing you want
}
else{
if (FBSession.activeSession.isOpen) {
[[FBRequest requestForMe] startWithCompletionHandler:^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) {
if (!error) {
NSlog(#"user ID %#",[user objectForKey:#"id"]);
}else{
[self hideLoadingMode];
}
}];
}
}
}];
i hope this help you

AFNetworking Error Domain Code=-999 ? But works fine?

I'm getting a strage error from AFNetworking even the though the request seems to work fine (as the change actually happens on the site).
Error Domain=NSURLErrorDomain Code=-999 "The operation couldn’t be completed
(NSURLErrorDomain error -999.)" UserInfo=0x1fd4a080
{NSErrorFailingURLKey=http://gcm.greenlightdispatch.com/services/json/}
The strange thing is that it returns this error but it actually doesn't have a problem completing the request (on the server, the information passes through just fine and all).
AFHTTPClient *httpClient = [[[AFHTTPClient alloc] initWithBaseURL:url] autorelease];
[httpClient postPath:#"" parameters:[NSDictionary dictionaryWithDictionary:params]
success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(#"Success: %#", [responseObject objectFromJSONData]);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(#"Error: %#", error.description);
}];
Thanks for the help
This has been answered many times before. The operation is being canceled which is why you get that error.
What to do about an NSURLErrorDomain -999?

Resources