Skip to content

Instantly share code, notes, and snippets.

@samcroft
Created July 25, 2016 13:28
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 samcroft/888f9d09e9e7e31935d8145ded4d4c66 to your computer and use it in GitHub Desktop.
Save samcroft/888f9d09e9e7e31935d8145ded4d4c66 to your computer and use it in GitHub Desktop.
<?php
header('Content-Type: application/json');
$callback = isset($_GET['callback']) ? $_GET['callback'] : false;
$comicId = isset($_GET['id']) && is_numeric($_GET['id']) ? $_GET['id'] : null;
$comics = array(
array('id'=>19242,'title'=>'Star Wars'),
array('id'=>19379,'title'=>'Darth Vader'),
array('id'=>19631,'title'=>'Princess Leia'),
array('id'=>19486,'title'=>'Kanan The Last Padawan')
);
if ($comicId) {
switch ($comicId) {
case 19242:
$output = array('id'=>19242,'title'=>'Star Wars','description'=>'Following the heroes of the Rebel Alliance between the events of Star Wars: Episode IV A New Hope and Star Wars: Episode V The Empire Strikes Back.','characters'=>array('Luke Skywalker', 'Han Solo', 'Princess Leia Organa', 'Chewbacca', 'R2-D2', 'C-3PO'));
break;
case 19379:
$output = array('id'=>19379,'title'=>'Darth Vader','description'=>'Following Darth Vader between the events of Star Wars: Episode IV A New Hope and Star Wars: Episode V The Empire Strikes Back','characters'=>array('Darth Vader', 'Dr. Aphra', 'BT-1', '0-0-0'));
break;
case 19631:
$output = array('id'=>19631,'title'=>'Princess Leia','description'=>'Beginning during the award ceremony in the Rebel base on Yavin 4, picking up moments after Star Wars: Episode IV A New Hope left off.','characters'=>array('Princess Leia Organa', 'Evaan Verlaine', 'R2-D2'));
break;
case 19486:
$output = array('id'=>19486,'title'=>'Kanan The Last Padawan','description'=>'Prequel to the animated television series Star Wars Rebels, telling the story of Kanan Jarrus in the aftermath of Order 66.','characters'=>array('Kanan Jarrus', 'Caleb Dume', 'Jedi Master Depa Billaba'));
break;
}
} else {
$output = $comics;
}
$output = json_encode($output);
if ($callback) {
echo sprintf('%s(%s)', $callback, $output);
} else {
echo $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment