Skip to content

Instantly share code, notes, and snippets.

@guillorrr
Created January 28, 2024 00:35
Show Gist options
  • Select an option

  • Save guillorrr/866b3ddef262c0cd80397886649795fb to your computer and use it in GitHub Desktop.

Select an option

Save guillorrr/866b3ddef262c0cd80397886649795fb to your computer and use it in GitHub Desktop.
api request debug
<?php
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
header("Allow: GET, POST, OPTIONS, PUT, DELETE");
$method = $_SERVER['REQUEST_METHOD'];
if($method == "OPTIONS") {
die();
}
header('Content-Type: application/json');
$request = file_get_contents('php://input');
$req_dump = print_r($request, true);
$json_data = file_put_contents('api.log', $req_dump);
$action = json_decode($json_data, true);
var_dump($action);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment