Skip to content

Instantly share code, notes, and snippets.

@pmachapman
Created May 13, 2024 02:55
Show Gist options
  • Save pmachapman/b3215ee3379ee2a6ddb3874635e57667 to your computer and use it in GitHub Desktop.
Save pmachapman/b3215ee3379ee2a6ddb3874635e57667 to your computer and use it in GitHub Desktop.
A script to help test webhooks
<?php
// Open the file for writing
$objFile = fopen("output.txt", 'w');
// Record server variables
fwrite($objFile, "Server Variables\n");
foreach ($_SERVER as $variableName => $value) {
fwrite($objFile, $variableName . ": " . $value . "\n");
}
fwrite($objFile, "\n");
// Record query string variables
fwrite($objFile, "Query String\n");
foreach ($_GET as $variableName => $value) {
fwrite($objFile, $variableName . ": " . $value . "\n");
}
fwrite($objFile, "\n");
// Record form variables
fwrite($objFile, "Form\n");
foreach ($_POST as $variableName => $value) {
fwrite($objFile, $variableName . ": " . $value . "\n");
}
fwrite($objFile, "\n");
// Record session variables
fwrite($objFile, "Session\n");
foreach ($_SESSION as $variableName => $value) {
fwrite($objFile, $variableName . ": " . $value . "\n");
}
fwrite($objFile, "\n");
// Record cookies
fwrite($objFile, "Cookies\n");
foreach ($_COOKIE as $variableName => $value) {
fwrite($objFile, $variableName . ": " . $value . "\n");
}
fwrite($objFile, "\n");
// Record HTTP headers
fwrite($objFile, "HTTP Headers\n");
foreach (getallheaders() as $variableName => $value) {
fwrite($objFile, $variableName . ": " . $value . "\n");
}
fwrite($objFile, "\n");
// Record the raw body
fwrite($objFile, "Raw Body\n");
fwrite($objFile, file_get_contents('php://input'));
// Close the file
fclose($objFile);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment