Created
August 30, 2016 14:46
-
-
Save economysizegeek/4559cbeb5cea941b85509907269bf1ca to your computer and use it in GitHub Desktop.
Make a php endpoint that simulates a slow API Call
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 | |
//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