这是向客户发送带有文件(图片)的消息。您好,请帮忙。现在我只能发送到一个号码。如何向多个号码发送时事通讯。
<!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/popper.js@1.16.0/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;
}
?>
我尝试了不同的选项,但没有帮助,也许有兴趣的人可以帮助解决方案(添加)邮寄到超过 1 个号码