2010-03-06 48 views
1

因此,客户现在要求我发送与他在Coldfusion中给出的示例同步的请求,并且看到我对Coldfusion没有真正的体验,因此我在想如何才能在iPhone上运行下面的命令(请求):Coldfusion调用Objective-C

<cfhttp method="post" 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" /> 

预先感谢您!非常感谢!

回答

2

这应该是相等的(未经测试,虽然):

NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://6Z3YcQhPTZWcCHG0o9OcFA:[email protected]/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 
} 

如果您需要帮助,除此之外,你将需要阅读URL Loading System reference

0

iPhone没有Coldfusion运行时。

+3

是的,但是看起来这只是一个执行HTTP POST的命令,这肯定是可行的。 – 2010-03-06 04:32:38