Answer the question
In order to leave comments, you need to log in
How to send sms (or in general how to execute any php code) while submitting a modx form?
Until recently, I sent SMS with the data of the completed form and recorded the same form data in the google spreadsheet simply through
an external form handler written in php :) in which this was solved simply, there were 2 codes after the form was successfully submitted)
this is a call to the sms.ru API
<?php
$ch = curl_init("http://sms.ru/sms/send");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
"api_id" => "9999999999999",
"to" => "8888888888888",
"text" => $name ." ". $phone
));
$body = curl_exec($ch);
curl_close($ch);
$nik =$getdata['name']['value'];
$tell=$getdata['tell']['value'];
$mile=$getdata['e-mail']['value'];
$text=$getdata['text']['value'];
$chek=$getdata['checkbox']['value']." ". $getdata['radio']['value']." " . $getdata['select']['value'];
$utm=$getdata['utm-name']['value'];
// формируем запись в нашу таблицу google
$url = "99999999999999999999999999999999999999999999999999999999";
$_POST['fio'] = $nik;
$_POST['tell']=$tell;
$_POST['chek']=$chek;
$_POST['e-mail']=$mile;
$_POST['text']=$text;
$_POST['utm-name']=$utm;
$draftResponse = ",,4503709590584940035";
$pageHistory = "0";
$fbzx = "3880320875455510089";
$post_data = array (
"entry.404904442" => $_POST['fio'],
"entry.2144695223" => $_POST['tell'],
"entry.481061397" =>$_POST['chek'],
"entry.568776889" =>$_POST['e-mail'],
"entry.516856755" =>$_POST['text'],
"entry.592606563"=>$_POST['utm-name'],
"draftResponse" => "[,,4503709590584940035;]",
"pageHistory" => "0",
"fbzx" => "4503709590584940035"
);
// заносим данные в сам google
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// указываем, что у нас POST запрос
curl_setopt($ch, CURLOPT_POST, 1);
// добавляем переменные
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
//заполняем таблицу google
$output = curl_exec($ch);
curl_close($ch);
//
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question