Tag: http

Sharing NSOperationQueue across View Controllers?

I’m using an NSOperationQueue to manage HTTP connections (using ASI-HTTPRequest). Since I have multiple views and the need to have these different views requesting HTTP connections, should I try to create a global NSOperationQueue in the app delegate, or should I have one in each of the views? I’m not familiar with NSOperationQueue. I’d like […]

Get Variable from httpcontext coming from NSUrlRequest

This question will be a nice tutorial for http connection “POST” between Iphone and asp.net server 🙂 what i’m trying to do is to send an image from iphone to Asp.net server; Here my uploadImage fonction in objective-c : – (IBAction)uploadImage { /* turning the image into a NSData object getting the image back out […]

How to make NSURLRequest to obtain a Twitter request token?

I am trying to obtain a request token from Twitter with this code: NSMutableURLRequest *mURLRequest = [[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:@”https://api.twitter.com/oauth/request_token”]]; mURLRequest.HTTPMethod = @”POST /oauth/request_token HTTP/1.1″; [mURLRequest setValue:@”User-Agent” forHTTPHeaderField:@”Coupled HTTP”]; [mURLRequest setValue:@”OAuth oauth_callback=\”http%3A%2F%2Fbytolution.com\”” forHTTPHeaderField:@”Authorization”]; [mURLRequest setValue:@”api.twitter.com” forHTTPHeaderField:@”Host”]; [mURLRequest setValue:@”Accept” forHTTPHeaderField:@”*/*”]; NSHTTPURLResponse *urlResponse; NSError *error; NSError *serializationError; NSData *responseData = [NSURLConnection sendSynchronousRequest:mURLRequest returningResponse:&urlResponse error:&error]; NSLog(@”data: %@, response:%@, error: […]

Simple objective-c GET request

Most of the information here refers to the abandoned ASIHTTPREQUEST project so forgive me for asking again. Effectively, I need to swipe a magnetic strip and send the track 2 data to a webservice that returns “enrolled” or “notenrolled” (depending on the status of the card…) So my data comes in simply as NSData *data […]

NSURLRequest – encode url for NSURLRequest POST Body (iPhone objective-C)

I am sending a post using NSURLRequest. NSURL *url = [NSURL URLWithString:someUrlString]; NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url]; NSString *msgLength = [NSString stringWithFormat:@”%d”, [parameterString length]]; [theRequest addValue: msgLength forHTTPHeaderField:@”Content-Length”]; [theRequest setHTTPMethod:@”POST”]; [theRequest setHTTPBody: [parameterString dataUsingEncoding:NSUTF8StringEncoding]]; Within the body of the Request I am encoding the following NVP: returnURL=http://someSite.com The post is going through successfully, but I […]

COMET (server push to client) on iPhone

I’m looking to establish some kind of socket/COMET type functionality from my server(s) to my iPhone application. Essentially, anytime a user manages to set an arbitrary object ‘dirty’ on the server, by say, updating their Address.. the feedback should be pushed from the server to any clients keeping a live poll to the server. The […]

Add HTTP Header to NSURLRequest

Is there any way to add HTTP header to NSURLRequest object? I used to add them in NSMutableURLRequest using: [request addValue:@”PC” forHTTPHeaderField:@”machineName”]

Can I use NSURLCredentialStorage for HTTP Basic Authentication?

I have a cocoa class set up that I want to use to connect to a RESTful web service I’m building. I have decided to use HTTP Basic Authentication on my PHP backend like so… <?php if (!isset($_SERVER[‘PHP_AUTH_USER’])) { header(‘WWW-Authenticate: Basic realm=”My Realm”‘); header(‘HTTP/1.0 401 Unauthorized’); //Stuff that users will see if they click ‘Cancel’ […]

Tutorials for using HTTP POST and GET on the iPhone in Objective-C

I downloaded apple’s demo for using HTTP POST and GET (Their sample app has a tabbar with different parts) and the code is so confusing! Could anybody give me some sample code or a link to some tutorials about it? 🙂 Thanks!

SVN+SSH Connection Giving Error 210002, Network Connection Closed Unexpectedly

OK, I’m having a problem settings up SVN+SSH. I have SVN running on a Linux server and trying to connect from a Mac laptop running Snow Leopard. XCode tries to connect, but gives the message “Error 210002, network connection closed unexpectedly.” Nothing online seems to explain. I connect using xcode with HTTP and it works […]