fork download
  1. <?php
  2. // API Key and Device ID
  3. $api_key = '6f55231f-5112-486e-9f81-11f6ed30accf';
  4. $device_id = '66f5782d65c9fd8b407af018';
  5.  
  6. // SMS Details
  7. $recipients = ['+254794131895']; // Replace with the recipient's phone number
  8. $message = 'Hello World!';
  9.  
  10. // Prepare the payload
  11. $data = [
  12. 'recipients' => $recipients,
  13. 'message' => $message
  14. ];
  15.  
  16. // Initialize cURL
  17. $ch = curl_init();
  18.  
  19. // Set cURL options
  20. curl_setopt($ch, CURLOPT_URL, "https://a...content-available-to-author-only...e.dev/api/v1/gateway/devices/$device_id/sendSMS");
  21. curl_setopt($ch, CURLOPT_POST, 1);
  22. curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
  23. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  24.  
  25. // Set headers
  26. curl_setopt($ch, CURLOPT_HTTPHEADER, [
  27. 'x-api-key: ' . $api_key,
  28. 'Content-Type: application/json'
  29. ]);
  30.  
  31. // Execute cURL request and capture the response
  32. $response = curl_exec($ch);
  33.  
  34. // Check for errors
  35. if (curl_errno($ch)) {
  36. echo 'Error:' . curl_error($ch);
  37. } else {
  38. // Print the response from the API
  39. echo 'Response: ' . $response;
  40. }
  41.  
  42. // Close cURL session
  43. ?>
  44.  
Success #stdin #stdout 0.03s 26160KB
stdin
Standard input is empty
stdout
Error:Could not resolve host: api.textbee.dev