WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I am using Wordpress 3.3.1 and building a small API to be able to send an SMS to insert data.

 * Template Name: API: Response



The following $_POST variables are being sent from the SMS provider


When using $_POST['message'], $_GET['message'] or $_REQUEST['message'] Wordpress gives me a 404. Works like a charm when using $_POST['_message'].

Any ideas? Can't find it in the reserved taxanomies.

share|improve this question

marked as duplicate by toscho Jul 6 '13 at 16:53

This question was marked as an exact duplicate of an existing question.

Try var_dump( $_REQUEST ); instead of print_r('hello');. – Ralf912 May 7 '13 at 14:13

To insert a post into the WordPress database, whether you are doing it as a logged in user to the current WordPress installation or over XML-RPC (or any other remote methodology) you need to be using something along the lines of;

  $the_post = array(
     'post_title' => 'Post Title',
     'post_content' => 'My post content',
     'post_status' => 'publish',
     'post_author' => 1,

  wp_insert_post( $the_post );

In the case of using a form or some other programmatic means to insert a post, your code might look like this;

  $the_post = array(
     'post_title' => 'Post Title',
     'post_content' => $_POST['message'],
     'post_status' => 'publish',
     'post_author' => 1,

  wp_insert_post( $the_post );

The bottom line is this, no matter how you decide to insert a post - be it via sending an SMS, using a remote form, smoke signal or the like - your code that handles and processes the data to be inserted must reflect the above examples (in its most simplistic form).

So, what does your code look like that is handling the processing of your incoming SMS message?


wp_insert_post - WordPress Codex

share|improve this answer
I have no issues creating the page, but when using $_POST['message'] (or any other than that) I receive a 404 from Wordpress. I've even cleared everything from the template, only using this: <?php /** * Template Name: API: Response * */ print_r('hello'); ?> /api/response/?message=lalalala Gives a 404. /api/response/?_message=laalalal /api/responsie/?Message=lalalal Does not give a 404. – Viktor Sarström May 29 '12 at 6:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.