没有从$ _post获取值

时间:2015-04-24 13:06:18

标签: php ios objective-c web-services afnetworking

我有以下代码:

 if (isset($_POST["medewerker"])) {  
            $output = array();
            $output['status'] = 200;
            $output['message'] = $_POST["medewerker"];
            sendResponse(200, json_encode($output));
            return true;
        }else{
                $output = array();
                $output['status'] = 501;
                $output['message'] = ' NIET-OK';
                 sendResponse(200, json_encode($output));
                return true;
        }

当我尝试在我的应用中调用此功能时:

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
  manager.requestSerializer = [AFJSONRequestSerializer serializer];
    NSMutableDictionary *params = [[NSMutableDictionary alloc]init];
    [params setObject:@"stef" forKey:@"medewerker"];
    [params setObject:@"sanmax" forKey:@"klant"];
    [params setObject:@"nota 123456" forKey:@"nota"];
    [params setObject:strDate1 forKey:@"start"];
    [params setObject:strDate2 forKey:@"einde"];



    NSData *imageData = UIImageJPEGRepresentation(self.imgSignature.image, 0.1);
    [params setObject:imageData forKey:@"tmp_name"];


    NSData* uploadFile = nil;
    if ([params objectForKey:@"tmp_name"]) {
        uploadFile = (NSData*)[params objectForKey:@"tmp_name"];
        [params removeObjectForKey:@"tmp_name"];
    }

    [manager POST:baseURL parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
        if(uploadFile != nil){
            [formData appendPartWithFileData:uploadFile name:@"image" fileName:@"photo.jpg" mimeType:@"image/jpg"];
        }

    } success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSDictionary *json = (NSDictionary *)responseObject;
        NSLog(@"JSON IS %@",json);



    }failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"Error: %@", error);


    }];

我得到以下输出:

JSON IS {     message =&#34; NIET-OK&#34 ;;     status = 501; }

但就像你可以看到我确实设置了#34; medewerker&#34;。有什么帮助吗?

0 个答案:

没有答案