geminimac Posted June 4, 2014 Share Posted June 4, 2014 In my app I am using this code for sending parameters name, email, website url and comment in blog...Probably some value are wrong setting...Someone can help me solved? I'm going crazy!! Thanks in advance! -(void)invia{ NSURL *indirizzo = [NSURL URLWithString:@"http://z****.altervista.org/********/feed/"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[indirizzo standardizedURL]]; [request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData]; [request setHTTPShouldHandleCookies:NO]; [request setHTTPMethod:@"POST"]; //[request setValue:@"application/json" forHTTPHeaderField:@"Accept"]; NSDictionary *parametri = [NSDictionary dictionaryWithObjectsAndKeys: campoSito.text, @"url", campoNome.text, @"author", campoEmail.text, @"email", campoCommento.text, @"content", nil]; NSMutableArray *values = [NSMutableArray new]; [parametri enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { // Create an encoded parameter pair -> k=v NSString *p = [NSString stringWithFormat:@"%@=%@", key, [[obj description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; [values addObject]; }]; NSString *dati_postati = [values componentsJoinedByString:@"&"]; [request setValue:@"application/x-www-form-urlencoded; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [request setHTTPBody:[dati_postati dataUsingEncoding:NSUTF8StringEncoding]]; connetti = [[NSURLConnection alloc] initWithRequest:request delegate:self]; [connetti start]; [self dismissViewControllerAnimated:YES completion:nil]; campoCommento.text=nil; campoEmail.text=nil; campoSito.text=nil; campoNome.text=nil; } Link to comment https://www.insanelymac.com/forum/topic/298442-how-send-text-on-http-post-wordpress/ Share on other sites More sharing options...
geminimac Posted June 24, 2014 Author Share Posted June 24, 2014 more than 1600 views and no suggestions ... Link to comment https://www.insanelymac.com/forum/topic/298442-how-send-text-on-http-post-wordpress/#findComment-2033887 Share on other sites More sharing options...
Recommended Posts