<?php
$data = json_decode(file_get_contents("php://input"), true);

$token = $data['token'] ?? '';

if ($token) {
    file_put_contents("tokens.txt", $token . PHP_EOL, FILE_APPEND);
    echo "Saved";
} else {
    echo "No token";
}