SerwerSMS

$url = 'https://api2.serwersms.pl/messages/send_sms';

 $login = 'webapi_demo';

 $password = "password=demo";


 $postData = json_encode([
    'username' => 'webapi_tactica',
    'password' => 'SoWhat2020!',
    'phone' => '777777777',
    'text' => 'Witaj w programie Tactica. Twój kod PIN to: 1212',
    'sender' => 'tactica'
    ]
);
 function makeCurl($field,$url){
    $curl = curl_init($url);
    
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $field);
    curl_setopt($curl, CURLOPT_ENCODING, 'UTF-8');
    curl_setopt($curl, CURLOPT_HTTPHEADER, ['Content-Type: application/json','Content-Length: '.strlen($field)]);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_TIMEOUT, 10);
    //curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36');
    curl_setopt($curl, CURLOPT_HEADER, false);
    $result = curl_exec($curl);
   
    curl_close($curl);
  
    return $result;
}


$result = makeCurl($postData,$url);
      document.querySelectorAll('.et_pb_contact_submit.et_pb_button')[0].onclick=function(){

          var  imie = document.querySelector('#et_pb_contact_imię_0').value;
          var  nazwisko = document.querySelector('#et_pb_contact_nazwisko_0').value;
          var  email = document.querySelector('#et_pb_contact_adres_e-mail_0').value;
          //  phone = document.querySelector('#et_pb_contact_nr_tel_komorkowego_0').value;
           

           // console.log($('#et_pb_contact_adres_e-mail_0'));
        
           var postData = {
            "imie" : imie,
            "nazwisko" : nazwisko,
            "email" : email,
         
        };



           $.ajax({
            type: "POST",
            url: "/sms/wp-content/themes/Divi/call.php",
            data: postData, 
            success: function(data){
              alert(data);
            },
            // Alert status code and error if fail
            error: function (xhr, ajaxOptions, thrownError){
                alert(xhr.status);
                alert(thrownError);
            }
        });