Created
March 17, 2023 14:45
-
-
Save sibelius/0958ca0c74ac31050ec555a76cd16d7b to your computer and use it in GitHub Desktop.
simple php post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Set headers to allow cross-origin resource sharing (CORS) | |
header("Access-Control-Allow-Origin: *"); | |
header("Content-Type: application/json; charset=UTF-8"); | |
header("Access-Control-Allow-Methods: POST"); | |
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With"); | |
// Get the JSON data sent in the request body | |
$request_body = file_get_contents('php://input'); | |
// Decode the JSON data into a PHP object | |
$data = json_decode($request_body); | |
// Process the data (e.g. save it to a database) | |
// ... | |
echo json_encode($data); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment