diff options
Diffstat (limited to 'includes/jobs/PKFronters.php')
-rw-r--r-- | includes/jobs/PKFronters.php | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/includes/jobs/PKFronters.php b/includes/jobs/PKFronters.php index b1449a9..3c669d5 100644 --- a/includes/jobs/PKFronters.php +++ b/includes/jobs/PKFronters.php @@ -23,19 +23,22 @@ if ($app["other"]["id"] === $system) { echo("Not using authentication\n"); $ctx = stream_context_create([ 'http' => [ - 'method' => 'GET' + 'method' => 'GET', + 'headers' => "User-Agent: Mozilla/5.0 (+Cold-Haze/1.1)\r\n" ] ]); } echo("Fetching...\n"); +sleep(1); $data = file_get_contents("https://pluralkit.equestria.dev/v2/systems/$system/fronters", false, $ctx); +json_decode($data); -if (trim($data) !== "" && $data !== false) { +if (trim($data) !== "" && $data !== false && json_last_error() === JSON_ERROR_NONE) { echo("Data is valid, saved it\n"); file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/fronters.json", $data); } else { - echo("Data is invalid\n"); + echo("Data is invalid: " . json_last_error_msg() . ": " . $data . "\n"); } chdir($_SERVER['DOCUMENT_ROOT'] . "/includes/external/matrix"); |