-1

I have a Lora device sending Post Data. I have tested it on Free site called

https://webhook.site/#!/7365fbd2-1915-4668-b697-626f5eddb20e/8cfd61c3-9240-44bc-b683-bbb02b285ab9/1

Its receiving data like this image enter image description here

but when I try to use it in my PHP with below code

<?php


if ($_SERVER["REQUEST_METHOD"] == "POST") {
    file_put_contents('aa.txt',json_encode($_POST, true));
}

?>

Its log empty array like this

[]

I am not getting idea whats wrong with it and How I can solve it. Let me know if anyone can help me for same. Thanks!

Nidhi
  • 95
  • 9
  • Does this answer your question? [Receive JSON POST with PHP](https://stackoverflow.com/questions/18866571/receive-json-post-with-php) – CBroe Sep 21 '21 at 06:36

1 Answers1

0

To receive JSON string you can use this:

// Takes raw data from the request
$json = file_get_contents('php://input');

// Converts it into a PHP object
$data = json_decode($json);
W S
  • 362
  • 3
  • 4