kingston
kingston

Reputation: 1553

Send data from an iPhone to a Web service

I'm developing an iPad application in which a user fills in their details and presses a submit button, which sends the information to a specific Web server (which will later be viewed by a person)

As far as protocols for Web services are concerned, I know JSON and XML. Are there any other protocols that I should be looking into? (or perhaps by a different method completely)

I'd be very grateful for any help.

Upvotes: 4

Views: 4267

Answers (4)

PT Vyas
PT Vyas

Reputation: 704

Use AFNetworking for this.

AFNetworking is smart enough to load and process structured data over the network, as well as plain old HTTP requests. In particular, it supports JSON, XML and Property Lists (plists).

Upvotes: 0

Saurabh
Saurabh

Reputation: 22893

If you just want to send text info to server you can try this code:

NSString *textdata = [YourTextField text];
NSString *anotherTextdata = [YourAnotherTextField text];

NSString *urlpath;
urlpath = [@"http://yoursiteapiurl.com/" stringByAppendingString:@"yourserverfile.php?textdata="];
urlpath = [urlpath stringByAppendingString:textdata];
urlpath = [urlpath stringByAppendingString:@"&anotherTextData="];
urlpath = [urlpath stringByAppendingString:anotherTextdata];

NSURL *url=[[NSURL alloc] initWithString:[urlpath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

NSString *a = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];

The variable a will have the response of this URL. The server could send XML and then you can parse that XML using any XML parsing technique.

Upvotes: 5

user94896
user94896

Reputation:

If sending the data over HTTP is an option, I would recommend you look into the excellent ASIHTTPRequest library. As for encoding, I've found the json-framework library to be good.

Upvotes: 1

saadnib
saadnib

Reputation: 11145

you can use tbxml for it, its very easy to implement. Follow the link

http://www.tbxml.co.uk/TBXML/TBXML_Free.html

Upvotes: 1

Related Questions