$_POST['message'] gives a 404

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

?php 
/**
 * Template Name: API: Response
 *
 */

print_r('hello');

?

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

$_POST['message']
$_POST['from']

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.

Topic sms 404-error api Wordpress

Category Web


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?



References:

wp_insert_post - WordPress Codex

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.