Receive JSON POST Data

From Michael's Information Zone
Revision as of 10:02, 26 July 2018 by Michael.mast (talk | contribs) (Created page with "==Purpose== Request came across my desk for a web server to receive JSON POST data, providing web hooks for a business analyst to parse. On my end things were simple enough. #...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Purpose

Request came across my desk for a web server to receive JSON POST data, providing web hooks for a business analyst to parse. On my end things were simple enough.

  1. Simple Apache server to receive requests.
  2. Basic Authentication
  3. Save the POST data to file (For now, but I feel this will be expanded in the near future)

Process

[1][2]This example will echo the posted data back to the client during testing, as well as save the file to disk.

<?php
$myFile = "testFile.txt";
$data = file_get_contents('php://input');
echo $data;
file_put_contents($myFile,$data);
?>