检索在服务器上的PHP文件上使用NSRequest发布的数据

Here is the situation :

  • I have rented a server where php 5, apache2 are up and running.
  • I'm doing HTTP POST request on my iOS App using NSMutableURLRequest and NSURLConnnection.
  • I'm sending data as following :

    NSMutableDictionary *postDictionnnary = [NSMutableDictionary dictionaryWithObjects:@[@"login",username,password]
                                                                                forKeys:@[@"type",@"username",@"password"]];
    NSData *requestBodyData = [NSKeyedArchiver archivedDataWithRootObject:postDictionnnary];
    request.HTTPBody = requestBodyData;
    
    1. Is this the right way ?
    2. On my server, in my php file, where do i get those datas ? $_REQUEST seem empty.

Thanks !

try adding a method to request

request.HTTPMethod = @"POST"

In your php file, you should be able to retrieve your data using $_POST['key'];