Authentification avec POSTMethode ne renvoie pas correctement la réponse
hedi
Membre
Bonjour à tous
Je bloque sur une partie de mon appli qui consiste à authentifier un utilisateur
Mon petit souci c'est que quand je rentre mes identifiants correcte ça ne me renvoie pas le bon message de connexion réussie .
je ne sais pas ou est mon erreure mais je vous envoie le code quand meme
Mes NSLog ne renvoient rien du tout !!!!
Je ne sais pas ou est ce que j'ai merdé.
Any help please!!!!
Je bloque sur une partie de mon appli qui consiste à authentifier un utilisateur
Mon petit souci c'est que quand je rentre mes identifiants correcte ça ne me renvoie pas le bon message de connexion réussie .
je ne sais pas ou est mon erreure mais je vous envoie le code quand meme
-(IBAction)Connexion:(id)sender{<br /> <br /> //prepare json data<br /> NSString *user = userCell.text;<br /> NSString *password = passCell.text;<br /> <br /> NSDictionary *data = [[NSDictionary alloc] initWithObjectsAndKeys:<br /> user,// USERNAMEKEY,<br /> password, //PASSWORDKEY,<br /> nil];<br /> SBJsonWriter *json = [SBJsonWriter alloc];<br /> NSString *jsonString = [json stringWithObject:data];<br /> NSLog(@"toto = ", jsonString);<br /> <br /> [data release];<br /> [json release];<br /> <br /> //create/send http post request<br /> NSData *postData = [jsonString dataUsingEncoding:NSASCIIStringEncoding];<br /> <br /> NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];<br /> [request setURL:[NSURL URLWithString:@"https://mon_serveur/webservice/test.php"]];<br /> [request setHTTPMethod:@"POST"];<br /> [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];<br /> [request setHTTPBody:postData];<br /> <br /> NSURLResponse *urlResponse;<br /> NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:nil];<br /> [request release];<br /> NSString *jsonData = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];<br /> NSLog(@"toto = ", jsonData);<br /> <br /> //parse response json data<br /> // Create a dictionary from the JSON string<br /> @try<br /> {<br /> NSDictionary *response = [jsonData JSONValue];<br /> id user = [response objectForKey:@"user"];<br /> if(user != nil && [user isKindOfClass:[NSDictionary class]])<br /> {<br /> //go to next view<br /> TBPCollabListViewController *nextview = [[TBPCollabListViewController alloc] initWithStyle:UITableViewStyleGrouped];<br /> [self presentModalViewController:nextview animated:YES];<br /> [nextview release];<br /> }<br /> else<br /> {<br /> //alert <br /> UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"Error" <br /> message:@"invalid user/password!" delegate:nil <br /> cancelButtonTitle:nil otherButtonTitles:@"OK", nil];<br /> [myAlert show];<br /> [myAlert release];<br /> <br /> }<br /> }<br /> @catch (NSException * e)<br /> {<br /> //nothing to do here, just provent to crash when google location search does not work<br /> NSLog(@"NSException: ....");<br /> }<br /> @finally<br /> {<br /> [jsonData release];<br /> }<br />}<br />
Mes NSLog ne renvoient rien du tout !!!!
Je ne sais pas ou est ce que j'ai merdé.
Any help please!!!!
Connectez-vous ou Inscrivez-vous pour répondre.