2011-05-21 194 views
-1

我想将数据发送到服务器时,从iphone用户填写起坐,我用如何使用GET请求

NSURLRequest 

,但它与时空间的距离来坏网址返回将数据发送到服务器数据 请任何帮助

+0

你得到什么错误信息,你的代码是什么? – 2011-05-21 15:19:21

+0

http://xxxxxxxxxx.com/xxxxx/xxxxxx/mobile.php?method=createOrder&sid=dfdk6figau1reagpdv9sc6po67&dnumber=ali.jamali&odate=2011-05-21&ordate=2011-05-21&oshipto=shipopingto&otype=emergency&oatype=&oref=refrence&oshipvia=Shipping via&oashipvia = &opaymentmode =付款方式及ocomment =评论 – 2011-05-21 15:30:33

+0

误差theConenction错误域= NSURLErrorDomain代码= -1000 “错误的URL” 的UserInfo = 0x4b89750 {NSUnderlyingError = 0x4b897e0 “坏URL”,NSLocalizedDescription =不良URL} (GDB) – 2011-05-21 15:30:57

回答

2

,如果你要的只是发送了形式得到什么,一个可行的办法是:

NSString* urlWithParams = @"http://xxxxxxxxxx.com/xxxxx/xxxxxx/mobile.php?method=createOrder&sid=dfdk6figau1reagpdv9sc6po67&dnumber=ali.jamali&odate=2011-05-21&ordate=2011-05-21&oshipto=shipopingto&otype=emergency&oatype=&oref=refrence&oshipvia=Shipping"; 

NSString* escapedUrl = [urlWithParams stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 

现在使用escapedUrl的网址为您NSURLRequest。 如果您需要求助帮助,请告诉我。根据你的意见,我看到你的问题只是编码。

1

好吧,几件事情。第一个:你为什么使用GET? POST是一种用于发送数据的规范,例如来自表单。

第二:你是否将URL转换为net form?也就是说,他们的%-sign形式的非地址字符,如%20的空格?

+0

请参阅评论 – 2011-05-21 15:32:09

+0

请参阅第二点。该错误表示URL无法正确解析。转换为URL编码。 http://www.w3schools.com/TAGS/ref_urlencode.asp – 2011-05-21 15:43:10