Authentification avec POSTMethode ne renvoie pas correctement la réponse

hedihedi Membre
02:18 modifié dans Vos applications #1
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


-(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 />						&nbsp; user,// USERNAMEKEY,<br />						&nbsp; password, //PASSWORDKEY,<br />						&nbsp; nil];<br />	SBJsonWriter *json = [SBJsonWriter alloc];<br />	NSString *jsonString = [json stringWithObject:data];<br />	NSLog(@&quot;toto = &quot;, 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:@&quot;https://mon_serveur/webservice/test.php&quot;]];<br />	[request setHTTPMethod:@&quot;POST&quot;];<br />	[request setValue:@&quot;application/json&quot; forHTTPHeaderField:@&quot;Content-Type&quot;];<br />	[request setHTTPBody:postData];<br />	<br />	NSURLResponse *urlResponse;<br />	NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;urlResponse error:nil];<br />	[request release];<br />	NSString *jsonData = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];<br />	NSLog(@&quot;toto = &quot;, 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:@&quot;user&quot;];<br />		if(user != nil &amp;&amp; [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:@&quot;Error&quot; <br />															&nbsp; message:@&quot;invalid user/password!&quot; delegate:nil <br />													cancelButtonTitle:nil otherButtonTitles:@&quot;OK&quot;, 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(@&quot;NSException: ....&quot;);<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.