Read Raw POST data in PHP

In PHP, to get form inputs, $_POST can be used if the post has a key, such as name=something can be captured by $_POST['name'].

But what if it’s a raw post with only the post body and no key? Such as an xml api post?
Simple: use “php://input” as a text stream and read it with functions such as file_get_contents.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s