1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| #import <Foundation/Foundation.h>
#import <Foundation/NSObject.h>
NSString *ObjectiveCPeceolClient(NSString *stFichierPhp, NSString *stid, NSString *stNom, NSString *stPrenom, NSString *stIdentifiantSaisie, NSString *stIdentifiantLogin,
NSString *stTelSaisie, NSString *stTelDuTel, NSString *stmail, NSString *stType, NSString *stversion )
{
NSError *error;
//Création des paramètres de la méthode POST
NSString *bodyData = [NSString stringWithFormat:@"id=%@&Nom=%@&Prenom=%@&IdentifiantSaisie=%@&IdentifiantLogin=%@&TelSaisie=%@&TelDuTel=%@&mail=%@&Type=%@&version=%@",
stid,stNom,stPrenom,stIdentifiantSaisie,stIdentifiantLogin,stTelSaisie,stTelDuTel,stmail,stType,stversion];
NSMutableURLRequest *postRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:stFichierPhp]];
// Set the request's content type to application/x-www-form-urlencoded
[postRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
// Designate the request a POST request and specify its body data
[postRequest setHTTPMethod:@"POST"];
[postRequest setHTTPBody:[NSData dataWithBytes:[bodyData UTF8String] length:strlen([bodyData UTF8String])]];
//NSURLResponse *reponse;
NSData *response = [NSURLConnection sendSynchronousRequest:postRequest returningResponse:nil error:nil];
NSString *RetourValeur = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
return RetourValeur;
} |
Partager