'Whatsapp bulk message php
This is sending a message with a file (picture) to clients. Hello pls help. Now I can only send to one number. How can I send a newsletter to more than 1 number.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Отправка Сообщения</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
</head>
<body>
<div class="container">
<div class="row mt-5">
<div class="col-sm-3"></div>
<div class="col-sm-6">
<div class="card text-center">
<div class="card-header bg-primary text-white text-uppercase">
Отправка Сообщения
</div>
<div class="card-body">
<form action="" method="POST" enctype="multipart/form-data">
<div class="form-group">
<input type="text" name="mobile" value="<?=@$_POST['mobile']?>" placeholder="Номер Телефона" class="form-control" required>
</div>
<div class="form-group">
<input id="edit" type="file" class="form-control" name="image" required="">
</div>
<div class="form-group">
<textarea id="editable" name="message" class="form-control" placeholder="Сооenter code hereщение" required=""></textarea>
<script>
if (localStorage.getItem('text') !== null) {
document.getElementById('editable').value = localStorage.getItem('text');
}
document.addEventListener('keyup', function(e) {
localStorage.setItem('text', document.getElementById('editable').value);
});
</script>
</div>
<div class="form-group">
<input type="submit" name="submit" class="btn btn-success" value="Отправить Сообщение" >
</div>
</form>
</div>
<div class="card-footer text-center">
</div>
</div>
</div>
<div class="col-sm-3"></div>
</div>
</div>
<script src="js/save.js"></script>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script></body>
</body>
</html>
<?php
if(isset($_POST['submit']))
{
$mobile=$_POST['mobile'];
$message=$_POST['message'];
$filename=$_FILES['image']['name'];
$file_tmp=$_FILES['image']['tmp_name'];
$location="image/";
move_uploaded_file($file_tmp,$location.$filename);
//Whatsapp API
$apiURL = 'https://eu138.chat-api.com/instance189xxx/';
$token = 'fgjit273atf8xxxx';
$phone = $mobile;
$data = json_encode(array(
'chatId'=>$phone.'@c.us',
'body'=>'http://f0625631.xsph.ru/image/'.$filename,//FULL PATH and file name
'filename'=>$filename,
'caption'=>$message
));
$url = $apiURL.'sendFile?token='.$token;
$options = stream_context_create(['http' => [
'method' => 'POST',
'header' => 'Content-type: application/json',
'content' => $data
]
]);
$response = file_get_contents($url,false,$options);
echo $response; exit;
}
?>
I tried different options, but it didn’t help, maybe people who are interested can help with the solution (adding) mailing to more than 1 number
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
