Skip to content

Instantly share code, notes, and snippets.

@nooptr
Last active May 8, 2018 00:46
Show Gist options
  • Save nooptr/67540795d7f8c63e7e3503349b41855d to your computer and use it in GitHub Desktop.
Save nooptr/67540795d7f8c63e7e3503349b41855d to your computer and use it in GitHub Desktop.
Read request body sent from LINE App
<?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