Tag: http

AFNetworking 3.0 can't download image

I am trying to download an image using AFNetworking 3.0 doing this way: – (UIImage *) loadImage:(NSString *) link { __block UIImage *image = [UIImage imageNamed:@”no_user_profile_pic.png”]; AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; manager.responseSerializer = [AFImageResponseSerializer serializer]; [manager GET:[link stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]] parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject) { image = (UIImage *) responseObject; } failure:^(NSURLSessionTask *operation, NSError […]

Too many HTTP redirects

The problem doesn’t happen all the time. The error i’m getting is the following, Error Domain=NSURLErrorDomain Code=-1007 “too many HTTP redirects” UserInfo=0x14d18d40{NSErrorFailingURLStringKey=URLHERE, NSErrorFailingURLKey=URLHERE,NSLocalizedDescription=too many HTTP redirects, NSUnderlyingError=0x14d18a10 “too many HTTP redirects”} Could someone possibly give me an idea on what do here and point me in the right direction? Okay basically what i’m trying to […]

“untrusted server certificate” on iPhone

I am writing an iPhone application and I would like to connect to a ‘HTTPS’ server to get some information. However, I get the error in the console which is NSUnderlyingError = Error Domain=kCFErrorDomainCFNetwork Code=-1202 UserInfo=0x3e95cf0 “The certificate for this server is invalid. You might be connecting to a server that is pretending to be […]

How do I send the data I have in my sqlite database to the server with HTTP and JSON

I’m storing id,lat,lng, and timestamp in sqlite and now need to send it in an JSON object to the server. Here’s where I’m inserting the data. NSString *insertStatement = [NSString stringWithFormat:@”INSERT INTO location (latitude, longitude, timeStamp) VALUES (%g, %g, %@)”,newLocation.coordinate.latitude, newLocation.coordinate.longitude, newLocation.timestamp]; char *error; if ( sqlite3_exec(databasehandle, [insertStatement UTF8String], NULL, NULL, &error) == SQLITE_OK) { […]

ASIFormDataRequest POST Request Issue

im using this code to post data to my server NSURL *mainurl = [NSURL URLWithString:@”http://xxxxxxxxxx/api/PhonePaymentApi/Transaction/”]; NSString * postdata = [[NSString alloc]initWithFormat:@”UniqueId=%@&jsonProduct=%@&BranchId=%@&OrderToTime=%@”,GETUnicidentifire,JsonOrderDetail,BranchId,OrderToTime]; ASIFormDataRequest *requestt = [ASIFormDataRequest requestWithURL:mainurl]; [requestt setRequestMethod:@”POST”]; [requestt addRequestHeader:@”application/x-www-form-urlencoded” value:@”Content-Type”]; [requestt appendPostData:[postdata dataUsingEncoding:NSUTF8StringEncoding]]; NSString * theurl = [NSString stringWithFormat:@”%@”,mainurl]; NSURLRequest *thereqest = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:theurl]]; [NSURLConnection connectionWithRequest:thereqest delegate:self]; in the method – (void)connection:(NSURLConnection […]

How to download a web page with it's inner resoures like images,css in iOS?

I’m trying to download the specified web pages with their inner page resources to disk. When I send a NSURLRequest, only the initial URL would be request, but the resources as images,css,js would not be download. Someone suggests to use cache, but I don’t want to cache every web page browsed in the uiwebview, but […]

How to use Oauth properly

I haven’t made much progress, so rather then look for an answer to the error stated in my original question, I think my problem would best be solved by some overall instructions on how to use Oauth properly. Please look below to question reformulated. ORIGINAL QUESTION I’m using the cocoa-wrapper api for soundcloud on my […]

How would I send an NSArray filled with objects over a HTTP POST?

I have a product/shopping list (consisting of product objects with a name, product_id etc) on the iPhone side. I wish to send this list to the server where I will compare the list on the server with the one from the iphone (to merge the changes made and send the merged list back to the […]

What is the quickest way to get the String contents of a URL using Cocoa/iPhoneSDK?

Say I want to get the HTML of http://www.google.com as a String using some built-in classes of the Cocoa Touch framework. What is the least amount of code I need to write? I’ve gotten this far, but can’t figure out how to progress. There must be an easier way. CFHTTPMessageRef req; NSURL *url = [NSURL […]

NSHTTPURLResponse statusCode is returning zero when it should be 401

Possible Duplicate: iOS: How can i receive HTTP 401 instead of -1012 NSURLErrorUserCancelledAuthentication Just doing a normal HTTP post with a NSMutableURLRequest and sendSynchronousRequest. But the NSHTTPURLResponse object I pass in has a statusCode of zero after the call. I get this error: Error Domain=NSURLErrorDomain Code=-1012 UserInfo=0x4d3b3c0 “Operation could not be completed. (NSURLErrorDomain error -1012.)” […]