In PHP:
function github_curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "$url");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: token XXX_TOKEN"));
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
return curl_exec($ch);
}
$cache = github_curl("https://api.github.com/repos/LucLaverdure/Wizard.Build/releases/latest?client_secret=XXX_SECRET");
$cache = json_decode($cache, true);
$cache_file = $cache["zipball_url"];
// get zip file, build it if new
if (!file_exists(dirname(__FILE__)."/cache/".basename($cache_file).".zip")) {
$cache_download = github_curl($cache_file);
file_put_contents(dirname(__FILE__)."/cache/".basename($cache_file).".zip", $cache_download);
}
// list files within zip file (FTP ONLY)
$zip = new ZipArchive;
if ($zip->open(dirname(__FILE__)."/cache/".basename($cache_file).".zip") == TRUE) {
for ($i = 0; $i < $zip->numFiles; $i++) {
$filename = $zip->getNameIndex($i);
echo $filename."<br>";
}
}
Voila!