开发者

Coldfusion Calls in Objective-C

开发者 https://www.devze.com 2022-12-21 22:26 出处:网络
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 c

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开发者_StackOverflow社区" username="6Z3YcQhPTZWcCHG0o9OcFA" url="https://url.com/api/device_tokens/<devicetoken>" password="UL2PJ6UnSS6272afQJM2Jw">
<cfhttpparam name="Content-Type" value="application/json" type="header" />
<cfhttpparam value="{}" type="body" />

Thank you in advance! It is really appreciated!


This should be the equivalent (untested, though):

NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://6Z3YcQhPTZWcCHG0o9OcFA:UL2PJ6UnSS6272afQJM2Jw@url.com/api/device_tokens/<devicetoken>"]];
[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.


There's no Coldfusion runtime for the iPhone.

0

精彩评论

暂无评论...
验证码 换一张
取 消