fork download
  1. <?php
  2. $curl = curl_init();
  3. // OPTIONS:
  4. CURLOPT_URL => baseUrlWa . 'sendVerificationMessage',
  5. CURLOPT_RETURNTRANSFER => true,
  6. CURLOPT_ENCODING => '',
  7. CURLOPT_MAXREDIRS => 10,
  8. CURLOPT_TIMEOUT => 0,
  9. CURLOPT_FOLLOWLOCATION => true,
  10. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  11. CURLOPT_CUSTOMREQUEST => 'POST',
  12. CURLOPT_POSTFIELDS => array(
  13. 'phone_number' => '62895636931520',
  14. 'ttl' => 180,
  15. 'code' => $otpwa,
  16. 'code_lenght' => 6),
  17. CURLOPT_HTTPHEADER => array(
  18. 'Authorization: Bearer ' . 'AAEPGAAAJuGB_SNJ8UUdS4mdc8YAKdwNfLQhav0m1EGMWg',
  19. 'Content/Type: application/json'
  20. ),
  21. CURLOPT_SSL_VERIFYHOST => 0,
  22. CURLOPT_SSL_VERIFYPEER => 0,
  23.  
  24.  
  25. CURLOPT_HEADERFUNCTION =>
  26. function ($curl, $header) use (&$headers) {
  27. $len = strlen($header);
  28. $header = explode(':', $header, 2);
  29. if (count($header) < 2) // ignore invalid headers
  30. return $len;
  31.  
  32. $headers[strtolower(trim($header[0]))][] = trim($header[1]);
  33.  
  34. return $len;
  35. },
  36.  
  37.  
  38. ));
  39.  
  40.  
  41. $response = curl_exec($curl);
  42. $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); // this results 0 every time
  43. $res = json_decode($response, true);
  44.  
  45. if ($response === false || $httpCode != '200') {
  46. if ($response == !false) {
  47. if (isset($res['status_code']) || isset($res['error']))
  48. $response = $res['error'];
  49. else
  50. $response = "Maaf, terjadi error get OTP";
  51. } else
  52. $response = curl_error($curl);
  53. }
  54. else
  55. echo "salah";
  56.  
  57.  
  58. ?>
  59.  
Success #stdin #stdout #stderr 0.03s 26740KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Warning:  Use of undefined constant baseUrlWa - assumed 'baseUrlWa' (this will throw an Error in a future version of PHP) in /home/bvIWyB/prog.php on line 5
PHP Notice:  Undefined variable: otpwa in /home/bvIWyB/prog.php on line 16