fork download
  1. <?php
  2. $curl = curl_init();
  3.  
  4. // Set the API endpoint URL
  5. curl_setopt($curl, CURLOPT_URL, "https://r...content-available-to-author-only...s.com/v3.1/all");
  6.  
  7. // Set options for the cURL transfer
  8. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  9. curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
  10. curl_setopt($curl, CURLOPT_HTTPHEADER, [
  11. // Replace with your API key
  12. "Content-Type: application/json"
  13. ]);
  14.  
  15. // Execute the cURL request
  16. $response = curl_exec($curl);
  17.  
  18. // Check for errors
  19. if (curl_errno($curl)) {
  20. echo 'Error:' . curl_error($curl);
  21. } else {
  22. // Process the response
  23. echo $response; // You can decode it if it's JSON
  24. }
  25.  
  26. // Close the cURL session
  27. curl_close($curl);
  28. ?>
  29.  
Success #stdin #stdout 0.03s 26364KB
stdin
Standard input is empty
stdout
Error:Could not resolve host: restcountries.com