multi_artworks.php 605 B

12345678910111213141516171819202122232425
  1. <?php
  2. require_once __DIR__ . '/../include/config.php';
  3. require_once __DIR__ . '/../include/api.php';
  4. header('Content-Type: application/json');
  5. if (!isset($_GET['ids']) || !is_array($_GET['ids']) || count($_GET['ids']) > 50) {
  6. http_response_code(400);
  7. die('[]');
  8. }
  9. foreach($_GET['ids'] as $id) {
  10. if (!ctype_digit($id)) {
  11. http_response_code(400);
  12. die('[]');
  13. }
  14. }
  15. /* `11`: intentional, must be a valid user id for the endpoint to work */
  16. list($artworks, $error) = get_user_artworks(11, $_GET['ids']);
  17. if ($error) {
  18. http_response_code(500);
  19. die('[]');
  20. }
  21. echo json_encode($artworks->body->works);