Skip to content

Instantly share code, notes, and snippets.

@economysizegeek
Created August 30, 2016 14:46
Show Gist options
  • Save economysizegeek/4559cbeb5cea941b85509907269bf1ca to your computer and use it in GitHub Desktop.
Save economysizegeek/4559cbeb5cea941b85509907269bf1ca to your computer and use it in GitHub Desktop.
Make a php endpoint that simulates a slow API Call
<?php
//Copyright 2016 Dirk Elmendorf
//This simulates a slow request to a remote api
if (isset($_GET["seconds"]) && $_GET["seconds"] != "null") {
$seconds = $_GET["seconds"];
}
else {
$seconds = 5;
}
sleep($seconds);
header('Content-Type: application/json');
$data = array('delay' => $seconds);
echo(json_encode($data));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment