欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

c语言 get post请求,URL GET/POST请求目标-c

发布时间:2025/3/20 编程问答 44 豆豆
生活随笔 收集整理的这篇文章主要介绍了 c语言 get post请求,URL GET/POST请求目标-c 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

我必须向localhost发送get或post请求:

if(@$_GET['option']) {

echo "You said \"{$_GET['option']}\"";

}else if(@$_POST['option']) {

echo "You said \"{$_POST['option']}\"";

}

?>

我用这个代码:

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://localhost/wsh/index.php?option=Hello"]];

NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];

NSString *get = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];

它有效,但有一次在代码中.如果生病了另一次,申请已经终止.

我尝试使用ASIFormDataRequest:

ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:@"http://localhost/wsh/index.php"] autorelease];

[request setPostValue:@"option" forKey:@"myFormField1"];

[request start];

NSError *error = [request error];

if (!error) {

NSString *response = [request responseString];

NSLog(response);

}else{

NSLog(@"error");

}

它说:

2010-01-07 13:20:34.964 WSH[3351:903] -[NSCFString absoluteURL]: unrecognized selector sent to instance 0x160f8

2010-01-07 13:20:34.966 WSH[3351:903] error

我的英语

总结

以上是生活随笔为你收集整理的c语言 get post请求,URL GET/POST请求目标-c的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。