开发者

parse POST request from HTTP Request body

开发者 https://www.devze.com 2023-02-18 10:42 出处:网络
What is the best and easiest way to get the HTTP开发者_运维问答 Body from the POST request and parse it with variables? Say I have two attributes called latitude and longitude in the body in which the

What is the best and easiest way to get the HTTP开发者_运维问答 Body from the POST request and parse it with variables? Say I have two attributes called latitude and longitude in the body in which the values I want to extract.

Another thing is how can I test it so I can see these values?


In your PHP which handles the POST request you can do something like:

$latitude = $_POST['latitude'];
$longitude = $_POST['longitude'];

Some browsers have developer tools that allow you to see the POST data that the browser sent. I use the FireBug plug-in for Firefox. I think the built-in developer tools in IE 8 and above (F12 I think) can do the same thing. Not sure about Chrome, but I'm sure there's something around.


You're a little unclear in your question, if what you're asking is how to get the values of post variables, then PHP has the $_POST super global that you can reference as $_POST['key'].

If what you're asking is how to get some xml or something from the post body and parse it for values you might try the $HTTP_RAW_POST_DATA super global. It would depend how the data is formatted when it gets there.


read to $_POST like this:

echo '<pre>';
  print_r ( $_POST );
echo '</pre>'

and to access: $_POST [variablename] read more at: http://us2.php.net/manual/en/reserved.variables.post.php

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号