fork download
  1. <?php
  2. $url = "http://54.85.96.159:5001/tokens/allocation"; // Ensure the URL includes the protocol
  3.  
  4. $data = [
  5. "email" => "dilipkumar.gupta@reseit.in",
  6. "cost" => 5
  7. ];
  8.  
  9. // Convert data to JSON
  10. $jsonData = json_encode($data);
  11.  
  12. // Initialize cURL
  13. $ch = curl_init($url);
  14.  
  15. // Set cURL options
  16. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  17. curl_setopt($ch, CURLOPT_HTTPHEADER, [
  18. "Content-Type: application/json",
  19. "Accept: application/json"
  20. ]);
  21. curl_setopt($ch, CURLOPT_POST, true);
  22. curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
  23. curl_setopt($ch, CURLOPT_TIMEOUT, 30); // Optional: Increase timeout
  24.  
  25. // Execute request
  26. $response = curl_exec($ch);
  27.  
  28. // Check for errors
  29. if (curl_errno($ch)) {
  30. echo "cURL erro hai.........r: " . curl_error($ch);
  31. error_log("cURL error (" . curl_errno($ch) . "): " . curl_error($ch));
  32. }
  33.  
  34. // Close cURL
  35.  
  36. // Print response
  37. echo $response;
  38. ?>
  39.  
Success #stdin #stdout #stderr 0.03s 25996KB
stdin
Standard input is empty
stdout
cURL erro hai.........r: 
stderr
cURL error (7):