diff options
Diffstat (limited to '_site/includes/modules/github.php')
-rw-r--r-- | _site/includes/modules/github.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/_site/includes/modules/github.php b/_site/includes/modules/github.php new file mode 100644 index 0000000..596d984 --- /dev/null +++ b/_site/includes/modules/github.php @@ -0,0 +1,22 @@ +<?php
+function gh_api($api) {
+ $crl = curl_init("https://api.github.com/" . $api);
+ curl_setopt($crl, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($crl, CURLINFO_HEADER_OUT, true);
+ curl_setopt($crl, CURLOPT_POST, false);
+
+ curl_setopt($crl, CURLOPT_HTTPHEADER, array(
+ 'Content-Type: application/json',
+ "Accept: application/json",
+ "Authorization: token " . json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/admin/credentials.json"), true)["token"],
+ "User-Agent: UnchainedTech-Admin/0.0.0 (nekostarfan@gmail.com)"
+ ));
+
+ $result = curl_exec($crl);
+
+ if ($result === false) {
+ throw new ErrorException("GitHub API unexpectedly interrupted", 214, E_ERROR);
+ }
+
+ return $result;
+}
\ No newline at end of file |