【发布时间】:2012-02-06 15:53:49
【问题描述】:
我正在尝试从我的应用程序向我的网络服务器上的 php 文件发送建议,我已经在浏览器中测试了 php 脚本,该脚本向用户发送电子邮件并将建议存储在我的数据库中,一切正常.. 运行以下脚本时,我通过 IOS 成功连接,但我的数据库中没有收到结果..
NSString *post = [NSString stringWithFormat:@"http://blahblah.com/suggest.php?s=%@&n=%@&e=%@", suggestion, name, email];
// Create the request.
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:post]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
// create the connection with the request
// and start loading the data
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) {
NSLog(@"Connection establisted successfully");
} else {
NSLog(@"Connection failed.");
}
我检查了所有字符串并使用 %20 等对所有空格进行了编码。任何人都可以看出我的脚本无法运行的明显原因吗?
在不打开 Safari 的情况下从我的应用发出 HTTP 请求的最简单方法是什么?
【问题讨论】: