fork download
  1. <?php
  2.  
  3. // API URL
  4. $url = "https://f...content-available-to-author-only...i.com/products";
  5.  
  6. // Initialize cURL
  7. $ch = curl_init($url);
  8.  
  9. // Return response instead of printing
  10. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  11.  
  12. // Execute request
  13. $response = curl_exec($ch);
  14.  
  15. // Check for errors
  16. if ($response === false) {
  17. echo "Error: " . curl_error($ch);
  18. } else {
  19. echo $response;
  20. }
  21.  
  22. // Close cURL
  23.  
  24. ?>
  25.  
Success #stdin #stdout 0.05s 26268KB
stdin
Standard input is empty
stdout
Error: Could not resolve host: fakestoreapi.com