Php AWS Elastic Beanstalk应用程序未从iOS接收Post数据?
这个让我抓狂。我正在开发一个iOS应用程序,它可以与服务器来回通信。为了进行测试,我一直在使用本地ip进行开发,并在笔记本电脑上编写服务器端代码,使用XAMPP和PHP 我使用以下代码从iOS应用程序发送POST数据Php AWS Elastic Beanstalk应用程序未从iOS接收Post数据?,php,ios,cocoa-touch,amazon-web-services,amazon-elastic-beanstalk,Php,Ios,Cocoa Touch,Amazon Web Services,Amazon Elastic Beanstalk,这个让我抓狂。我正在开发一个iOS应用程序,它可以与服务器来回通信。为了进行测试,我一直在使用本地ip进行开发,并在笔记本电脑上编写服务器端代码,使用XAMPP和PHP 我使用以下代码从iOS应用程序发送POST数据 - (void)doAsyncPostWithCallback:(NSString *)method arguments:(NSDictionary *)arguments post:(NSDictionary *)post target:(id)target action:(SE
- (void)doAsyncPostWithCallback:(NSString *)method arguments:(NSDictionary *)arguments post:(NSDictionary *)post target:(id)target action:(SEL)action
{
NSString *urlRequestString = [NSString stringWithFormat:@"%@/%@", kApiUrl, method];
if ([MochiCart session].apiKey) {
urlRequestString = [NSString stringWithFormat:@"%@/apiKey/%@", urlRequestString, [MochiCart session].apiKey];
}
for (id key in arguments) {
NSString *argument = [NSString stringWithFormat:@"/%@/%@", key, [arguments objectForKey:key]];
urlRequestString = [urlRequestString stringByAppendingString:argument];
}
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlRequestString]];
if ([post count] > 0) {
NSString *postString = nil;
for (id key in post) {
NSString *keyValue = [post objectForKey:key];
postString = (postString) ? [postString stringByAppendingString:[NSString stringWithFormat:@"&%@=%@", key, keyValue]]: [NSString stringWithFormat:@"%@=%@", key, keyValue];
}
NSData *postData = [postString dataUsingEncoding:NSUTF8StringEncoding];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:postData];
}
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
id cTarget = (target) ? target : [NSNull null];
id cAction = (action) ? NSStringFromSelector(action) : [NSNull null];
[self.connectionInfos setObject:@{@"target" : cTarget, @"action" : cAction, @"responseData" : [[NSMutableData alloc] init]} forKey:[connection description]];
}
但是,当我将POST数据发送到笔记本电脑上的服务器时,这种方法非常有效——当将其发送到运行在AWS Elastic Beanstalk上的生产服务器时,响应就像根本没有接收任何POST数据一样。请求顺利通过,但由于某种原因,服务器端没有收到POST数据
我的第一个想法可能是AWS和通过移动设备发送POST数据无法协同工作(虽然这不重要),当然,使用iOS safari登录AWS应用程序的web部分也很好
所以,再一次。。有人知道为什么AWS没有使用我上面的代码来发送POST数据,但是我的本地服务器接收到了它,但没有任何线索吗?您的POST请求的HTTP响应是什么?问题是URL中没有www。