$app->post("/message", function($params){
<?=var_dump($params) ?> // пусто
$config = array(
'base_uri' => 'https://api.vk.com/method/',
'query' => [
'user_id'=>'********',
'message' => $params,
'attachment' => '********',
'random_id' => rand(1E9, 9E9),
'access_token' => '********',
'v' => '5.59',
'verify' => false]);
$client = new \GuzzleHttp\Client($config);
$response = $client->get("messages.send");
return json_decode($response->getBody(), true);
$.ajax({ url: '/message',
<form id="myform" action="/message" method="post">
<div class="form-group">
<input type="text" class="form-control" placeholder="Имя" name="name">
</div>
<div class="form-group">
<input type="tel" class="form-control" placeholder="+79180000001" pattern="(\+?\d[- .]*){7,13}" name="phone">
</div>
<button type="submit" class="btn">Отправить</button>
</form>
<form id="myform" action="/misc/" method="post">
<div class="form-group">
<input type="text" class="form-control" placeholder="Имя" name="name">
</div>
<div class="form-group">
<input type="tel" class="form-control" placeholder="+79180000001" pattern="(\+?\d[- .]*){7,13}" name="phone">
</div>
<button type="submit" class="btn">Отправить</button>
</form>
$("#myform").submit(function(e) {
e.preventDefault();
let f = $("#myform").serialize()+'&t='+$('.ticket-type').attr('data-info')+'&k='+$('.ticket-count').html();
$.ajax({
url: '/message',
type: 'post',
dataType: 'json',
data: f,
success: function(data) {
console.log(data);
$('#myform')[0].reset();
},
error: function(data) {
console.log(data);
}
});
});
});
$name = htmlspecialchars($_POST["name"]);
$phone = htmlspecialchars($_POST["phone"]);
$t_id = htmlspecialchars($_POST["t"]);
$t_qt = htmlspecialchars($_POST["k"]);
const arr = [{
"text": "foo",
"delay" : "2000"
},
{
"text": "bar",
"delay" : "2000"
},
{
"text": "bar1",
"delay" : "5000"
},{
"text": "bar",
"delay" : "1000"
}
];
function timeout(val){
return new Promise((resolve, reject)=>{
setTimeout(()=>{
console.log(val.text);
resolve();
}, val.delay);
});
}
(async () => {
for (const val of arr) {
await timeout(val);
}
console.log('Расчет окончен');
})();
for (i in data) {
var row = data[i];
var emailAddress = row[0]; // First column
var message = row[1]; // Second column
var subject = "Sending emails from a Spreadsheet";
MailApp.sendEmail(emailAddress, subject, message);
}