2010-03-06 44 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