views:

117

answers:

2

So a client right now is asking me to send requests that are synchronous to an example he gave me that is in Coldfusion, and seeing as I have no real experience with Coldfusion I was wondering how I could run the following command(request?) on the iPhone:

<cfhttp method="post" username="6Z3YcQhPTZWcCHG0o9OcFA" url="https://url.com/api/device_tokens/&lt;devicetoken&gt;" password="UL2PJ6UnSS6272afQJM2Jw">
<cfhttpparam name="Content-Type" value="application/json" type="header" />
<cfhttpparam value="{}" type="body" />

Thank you in advance! It is really appreciated!

A: 

There's no Coldfusion runtime for the iPhone.

rpetrich
Yes, but this looks like it's just a command to perform a HTTP POST, which is surely possible.
Kevin Reid
+1  A: 

This should be the equivalent (untested, though):

NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://6Z3YcQhPTZWcCHG0o9OcFA:[email protected]/api/device_tokens/&lt;devicetoken&gt;"]];
[theRequest addValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:[[NSString stringWithString:@"{}"] dataUsingEncoding:NSASCIIStringEncoding]];

NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) {
    // Create your data object here, then fill your object by responding to the appropriate delegate methods
} else {
    // NSError out
}

If you need help beyond that, you're going to have to read the URL Loading System reference.

Brock Batsell