fork download
  1. <?php
  2. $url = "http://115.245.30.253:8080/demo.php"; // Using HTTP instead of HTTPS
  3.  
  4. // Initialize cURL session
  5. $ch = curl_init();
  6. curl_setopt($ch, CURLOPT_URL, $url);
  7. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  8. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Ignore SSL verification if using HTTPS
  9. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  10. curl_setopt($ch, CURLOPT_TIMEOUT, 10); // Set timeout
  11. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Allow redirection
  12.  
  13. // Execute cURL request
  14. $json = curl_exec($ch);
  15.  
  16. // Check for cURL errors
  17. if ($json === false) {
  18. die("cURL Error: " . curl_error($ch));
  19. }
  20.  
  21. // Close cURL session
  22.  
  23. // Check if response is empty
  24. if (empty($json)) {
  25. die("No data found.");
  26. }
  27.  
  28. // Decode JSON response
  29. $data = json_decode($json, true);
  30.  
  31. // Check for JSON decode errors
  32. if (json_last_error() !== JSON_ERROR_NONE) {
  33. die("JSON Decode Error: " . json_last_error_msg() . "<br>Response: " . htmlspecialchars($json));
  34. }
  35.  
  36. // If the decoded data is empty or doesn't contain expected values
  37. if (empty($data)) {
  38. die("No data found.");
  39. }
  40.  
  41. // Display raw JSON response
  42. echo "<h3>Raw JSON Response:</h3>";
  43. echo "<pre>" . htmlspecialchars($json) . "</pre>";
  44.  
  45. // Display structured data
  46. echo "<h3>Formatted Response:</h3>";
  47. echo "<pre>";
  48. print_r($data);
  49. echo "</pre>";
  50.  
  51. ?>
  52.  
Success #stdin #stdout 0.02s 25764KB
stdin
Standard input is empty
stdout
cURL Error: