Last active
May 8, 2018 00:46
-
-
Save nooptr/67540795d7f8c63e7e3503349b41855d to your computer and use it in GitHub Desktop.
Read request body sent from LINE App
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 | |
$raw = file_get_contents('php://input'); | |
file_put_contents('/tmp/log_line_' . date('YYmmdd'), $raw . PHP_EOL, FILE_APPEND); | |
// ログ確認方法 | |
// https://example.com?log=1 | |
$log = filter_input(INPUT_GET, 'log', FILTER_SANITIZE_URL); | |
if ($log) { | |
$handle = popen("tail -f /tmp/log_line_" . date("YYmmdd") . " 2>&1", 'r'); | |
while(!feof($handle)) { | |
$buffer = fgets($handle); | |
echo "$buffer<br/>\n"; | |
ob_flush(); | |
flush(); | |
} | |
pclose($handle); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment