代码之家  ›  专栏  ›  技术社区  ›  Sj.

ColdFusion调用Objective-C

  •  1
  • Sj.  · 技术社区  · 14 年前

    所以现在一个客户要求我发送与他在ColdFusion中给我的一个例子同步的请求,并且鉴于我对ColdFusion没有实际经验,我想知道如何运行下面的命令(请求?)iPhone:

    <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 回复  |  直到 14 年前
        1
  •  2
  •   Brock Batsell    14 年前

    这应该是等效的(尽管没有测试):

    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
    }
    

    如果你需要更多的帮助,你必须阅读 URL Loading System reference .

        2
  •  0
  •   rpetrich    14 年前

    iPhone没有ColdFusion运行时。