Created
December 18, 2015 14:58
-
-
Save theseer/9be402757f8fba5abcc0 to your computer and use it in GitHub Desktop.
Redirect to the first attached file of the latest release
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(0); | |
ini_set('display_errors', false); | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, 'https://api.github.com/repos/<user>/<project>/releases'); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_USERAGENT, '<project> release redirector'); | |
$releasesRAW = curl_exec($ch); | |
curl_close($ch); | |
$releases = json_decode($releasesRAW); | |
$target = $releases[0]->assets[0]->browser_download_url; | |
header('Location: ' . $target , 302); | |
die('Forwarded to ' . $target); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment