試す:
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://admin.poslavu.com/cp/reqserv/"]];
[request setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"];
[request setHTTPBody:[[NSString stringWithFormat:@"dataname=tangere_techno&key=dBkeY&token=dBt0kEn&table=menu_groups"] dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPMethod:@"POST"];
NSError *error = nil; NSURLResponse *response = nil;
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
if (error) {
NSLog(@"Error:%@", error.localizedDescription);
}
else {
//success
}
データは XML 情報である必要がありますが、最初に解析する必要があります。詳細については、Apple のドキュメントを参照してください。リクエストを非同期にしようとしている場合は、これを試してください:
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://admin.poslavu.com/cp/reqserv/"]];
[request setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"];
[request setHTTPBody:[[NSString stringWithFormat:@"dataname=tangere_techno&key=dBkeY&token=dBt0kEn&table=menu_groups"] dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPMethod:@"POST"];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:req];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject){
NSData *data = (NSData *)responseObject;
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
[operation start];