fork download
  1.  
  2. <?php
  3.  
  4. // Initialize a cURL session
  5. $curl = curl_init();
  6.  
  7. // Set the URL to fetch
  8. curl_setopt($curl, CURLOPT_URL, "https://j...content-available-to-author-only...e.com/comments");
  9.  
  10. // Set options to return the transfer as a string
  11. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  12.  
  13. // Execute the cURL request
  14. $response = curl_exec($curl);
  15.  
  16. // Check for errors
  17. if (curl_errno($curl)) {
  18. echo 'cURL error: ' . curl_error($curl);
  19. } else {
  20. // Decode the JSON response
  21. $data = json_decode($response, true);
  22.  
  23. // Print the data
  24. print_r($data);
  25. }
  26.  
  27. // Close the cURL session
  28. curl_close($curl);
  29. ?>
  30.  
Success #stdin #stdout 0.04s 26332KB
stdin
Standard input is empty
stdout
cURL error: Could not resolve host: jsonplaceholder.typicode.com