fork download
  1. <?php
  2.  
  3. $url = "https://r...content-available-to-author-only...s.com/v3.1/all?fields=name,capital,population,continents,languages";
  4.  
  5. $ch = curl_init();
  6.  
  7. curl_setopt($ch, CURLOPT_URL, $url);
  8. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  9.  
  10. $response = curl_exec($ch);
  11.  
  12. if (curl_errno($ch)) {
  13. echo 'Error: ' . curl_error($ch);
  14. }
  15.  
  16.  
  17. $retrievedData = json_decode($response, true);
  18.  
  19. print_r($retrievedData);
Success #stdin #stdout 0.03s 25780KB
stdin
Standard input is empty
stdout
Error: Could not resolve host: restcountries.com