fork download
  1. <?php
  2.  
  3. // Define the API endpoint and parameters
  4. $url = "https://w...content-available-to-author-only...s.com/api/send/otp";
  5. $postFields = [
  6. "secret" => "7b37fcc2ce852de040c751f55b7e6d5f5270c4a0",
  7. "type" => "whatsapp",
  8. "message" => "Your OTP is {{otp}}",
  9. "phone" => "+77772319042",
  10. "expire" => 300
  11. ];
  12.  
  13. // Initialize cURL session
  14. $ch = curl_init();
  15.  
  16. // Set cURL options
  17. curl_setopt($ch, CURLOPT_URL, $url);
  18. curl_setopt($ch, CURLOPT_POST, true);
  19. curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
  20. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  21.  
  22. // Execute the request
  23. $response = curl_exec($ch);
  24. $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  25.  
  26. // Handle the response
  27. if ($http_code === 200) {
  28. echo "Success: " . $response;
  29. } else {
  30. echo "Error: HTTP Code " . $http_code . ", Response: " . $response;
  31. }
  32.  
  33. // Close cURL session
Success #stdin #stdout 0.04s 26068KB
stdin
Standard input is empty
stdout
Error: HTTP Code 0, Response: