fork download
  1. <?php
  2.  
  3. // URL of the API endpoint
  4. $url = 'https://b...content-available-to-author-only...x.com/trade/get_inr_valueapi';
  5.  
  6. // Initialize cURL session
  7. $ch = curl_init();
  8.  
  9. // Set cURL options
  10. curl_setopt($ch, CURLOPT_URL, $url);
  11. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  12. curl_setopt($ch, CURLOPT_TIMEOUT, 30); // Timeout in seconds
  13.  
  14. // Execute cURL request and capture the response
  15. $response = curl_exec($ch);
  16.  
  17. // Check for cURL errors
  18. if(curl_errno($ch)) {
  19. echo 'Error:' . curl_error($ch);
  20. }
  21.  
  22. // Close the cURL session
  23.  
  24. // Check if the response is not empty and is valid
  25. if ($response != '' && $response !== null) {
  26. try {
  27. // Decode JSON response
  28. $data = json_decode($response, true);
  29.  
  30. // Check if the keys exist in the decoded array
  31. if (isset($data['btc']) && isset($data['usdt']) && isset($data['kbusdt']) && isset($data['newusdt'])) {
  32. // Assign values to variables
  33. $btcval = $data['btc'];
  34. $usdtval = $data['usdt'];
  35. $kbval = $data['kbusdt'];
  36. $newusdt = $data['newusdt'];
  37.  
  38. // Optionally, you can echo or log these values
  39. // echo "BTC Value: " . $btcval . "\n";
  40. // echo "USDT Value: " . $usdtval . "\n";
  41. // echo "KB Value: " . $kbval . "\n";
  42. // echo "New USDT Value: " . $newusdt . "\n";
  43. } else {
  44. echo "Expected keys are missing in the response.";
  45. }
  46. } catch (Exception $e) {
  47. // Handle JSON parsing errors
  48. echo "Error parsing JSON: " . $e->getMessage();
  49. }
  50. } else {
  51. echo "No response or empty response received.";
  52. }
  53.  
  54. ?>
  55.  
Success #stdin #stdout 0.03s 26236KB
stdin
Standard input is empty
stdout
Error:Could not resolve host: bxkointrax.koinbx.comNo response or empty response received.