diff options
author | Minteck <46352972+Minteck@users.noreply.github.com> | 2021-07-20 01:15:15 +0200 |
---|---|---|
committer | Minteck <46352972+Minteck@users.noreply.github.com> | 2021-07-20 01:15:15 +0200 |
commit | af9e5ef458b93ef2003905e1ccc5665e7266c242 (patch) | |
tree | 989ac25a8b75578788cd7157308f37b9b83cf8f5 /includes/stats/refresh.php | |
download | main-af9e5ef458b93ef2003905e1ccc5665e7266c242.tar.gz main-af9e5ef458b93ef2003905e1ccc5665e7266c242.tar.bz2 main-af9e5ef458b93ef2003905e1ccc5665e7266c242.zip |
Commit
Diffstat (limited to 'includes/stats/refresh.php')
-rw-r--r-- | includes/stats/refresh.php | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/includes/stats/refresh.php b/includes/stats/refresh.php new file mode 100644 index 0000000..5499dd3 --- /dev/null +++ b/includes/stats/refresh.php @@ -0,0 +1,52 @@ +<?php + +require_once "./apis.php"; +$api = new API(); +$data = [ + "github" => [] +]; + +// ------------------------------------ +// GitHub + +$events = json_decode($api->GitHub("users/Minteck/events"), true); +$last = null; + +foreach ($events as $event) { + if ($event["type"] === "PushEvent") { + $last = $event; + break; + } +} + +$data["github"]["project"] = $last["repo"]["name"]; +$data["github"]["sha"] = substr($last["payload"]["commits"][0]["sha"], 0, 7); +$data["github"]["message"] = $last["payload"]["commits"][0]["message"]; + +// ------------------------------------ +// Reddit +$posts = json_decode($api->Reddit("user/Minteck"), true)["data"]["children"]; +$last = null; + +foreach ($posts as $post) { + if (!$post["pinned"]) { + $last = $post["data"]; + break; + } +} + +$data["reddit"]["sub"] = $last["subreddit"]; +$data["reddit"]["title"] = $last["title"]; +$data["reddit"]["score"] = $last["score"]; + +// ------------------------------------ +// Neutron Releases +$neutron = json_decode($api->GitHub("repos/Minteck-Projects/Neutron-Core/releases"), true); +file_put_contents("./gyrate-with-obliqueness.json", json_encode($neutron, JSON_PRETTY_PRINT)); +$neutron = json_decode($api->GitHub("repos/Minteck-Projects/Neutron-Core/tags"), true); +file_put_contents("./neutron2.json", json_encode($neutron, JSON_PRETTY_PRINT)); + +// ------------------------------------ +// Dump + +var_dump($data);
\ No newline at end of file |