Jump to content
Welcome to InsanelyMac Forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

  • Announcements

    • Allan

      Forum Rules   04/13/2018

      Hello folks! As some things are being fixed, we'll keep you updated. Per hour the Forum Rules don't have a dedicated "Tab", so here is the place that we have our Rules back. New Users Lounge > [READ] - InsanelyMac Forum Rules - The InsanelyMac Staff Team. 

How send text on HTTP POST wordpress?

2 posts in this topic

Recommended Posts

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!







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











Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.