Last active
August 29, 2015 14:06
-
-
Save apinstein/a2f1568863582e462239 to your computer and use it in GitHub Desktop.
php shutdown hook to generate curl request of the current request
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 | |
register_shutdown_function(function() { | |
$f = '/tmp/last-request-' . microtime(true) . '.sh'; | |
$rawData = json_decode(file_get_contents("php://input")); | |
$url = $_SERVER['REDIRECT_SCRIPT_URI']; | |
$requestData = http_build_query($_REQUEST); | |
$postData = NULL; | |
if ($_SERVER['REQUEST_METHOD'] === 'GET') | |
{ | |
$url .= "?{$requestData}"; | |
} | |
else | |
{ | |
$postData = "-d '{$requestData}'"; | |
} | |
file_put_contents($f, " | |
curl {$postData} '{$url}' | |
"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment