Jump to content

How send text on HTTP POST wordpress?


  • Please log in to reply
1 reply to this topic

#1
geminimac

geminimac

    Italian Staff Squad

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 1,417 posts
  • Gender:Male
  • Location:Modena

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:p];

        }];

        

        

        

        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;

      

    

    

}

 


#2
geminimac

geminimac

    Italian Staff Squad

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 1,417 posts
  • Gender:Male
  • Location:Modena

more than 1600 views and no suggestions ... :blush:







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

© 2014 InsanelyMac  |   News  |   Forum  |   Downloads  |   OSx86 Wiki  |   Mac Netbook  |   PHP hosting by CatN  |   Designed by Ed Gain  |   Logo by irfan  |   Privacy Policy