Skip to content

Instantly share code, notes, and snippets.

@theseer
Created December 18, 2015 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theseer/9be402757f8fba5abcc0 to your computer and use it in GitHub Desktop.
Save theseer/9be402757f8fba5abcc0 to your computer and use it in GitHub Desktop.
Redirect to the first attached file of the latest release
<?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