0

Could someone help with a simple PHP script to echo the whole message received with an HTTPPOST.

I am sending a string from an android app using HTTPPOST and would like to receive as a response the message received by the POST at the server.

The script that I am using will only echo name value pairs

echo $_POST('data')

works when I post form data, but have not figured out how to echo a string.

Thanks

Tori
  • 1,358
  • 4
  • 19
  • 38
  • This is a lot like: http://stackoverflow.com/questions/3718307/php-script-to-log-the-raw-data-of-post/3718333#3718333 except echo instead of output (if you search the site there are also lots of other questions along this line) – Rudu Sep 17 '10 at 16:36
  • Could just be a typo while entering here, but your sample is trying to use a variable function call. proper syntax is `$_POST['data']` (note the square brackets). – Marc B Sep 17 '10 at 16:54
  • It's a typo, thanks the script has [ ]. Thanks – Tori Sep 17 '10 at 17:30

2 Answers2

0
echo '<pre>',print_r($_POST),'</pre>';
Grumpy
  • 2,140
  • 1
  • 25
  • 38
0

Raw:

echo file_get_contents('php://input');

Possibly more easily parseble:

echo json_encode($_POST);
echo serialize($_POST);

For debugging purposes:

var_dump($_POST);
Wrikken
  • 69,272
  • 8
  • 97
  • 136