Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. [
  2. {
  3. "id": 1
  4. "nome": "José"
  5. },
  6. {
  7. "id": 2
  8. "nome": "João"
  9. }
  10.  
  11. ]
  12.  
  13. $path = explode('/', $_GET['path']);
  14. $contents = file_get_contents('tickets.json');
  15.  
  16. $json = json_decode($contents, true);
  17.  
  18. $method = $_SERVER['REQUEST_METHOD'];
  19.  
  20. header('Content-type: application/json');
  21. $body = file_get_contents('php://input');
  22.  
  23. if ($method === 'GET') {
  24. if ($json[$path[0]]) {
  25. echo json_encode($json[$path[0]]);
  26. }else{
  27. echo '[]';
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement