还有其他选择吗?
我正在使用Advanced Rest Client来测试我正在开发的 API。
我用 POST 发送 JSON。在代码中,$_FILES很好,但是file_get_contents("php://input")是空的。
如果我不发送任何文件,那么我可以使用file_get_contents("php://input")
PHP版本:5.6.4
我试图从我的应用程序发送一个建议到我的网络服务器上的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.");
}
Run Code Online (Sandbox Code Playgroud)
我检查了所有的字符串并使用%20等编码了所有空格.任何人都可以看到为什么我的脚本不起作用的任何明显的原因?
在不打开Safari的情况下,从我的应用程序发出HTTP请求的最简单方法是什么?