Kirim SMS Broadcast API berdasarkan group menggunakan select dropdown

Assalamualaikum. saya mau bertanya. saya buat sms broadcast menggunakan API berdasarkan group cluster pelanggan. hanya saja ada maslah saat ngirim SMS broadcast. phone number yang terkirim hanya 1 dari group yg saya pilih. bagaimana caranya untuk mengambil semua phone number dari group cluster yang saya pilih di select dropdown.

code di view

send_broadcast_form.php

 <form action="<?= site_url('sms_marketing/sendSMS') ?>" method="post">
                            <div class="form-group">
                                <label>Isi Pesan *</label>
                                <textarea name="message" value="" style="height: 100px;" class="form-control" required></textarea>
                            </div>
                            <div class="form-group">
                                <label>Penerima *</label>
                                <select name="recipient" id="recipient" class="form-control">
                                    <option value="">Select</option>
                                    <?php
                                    $link  = mysqli_connect("127.0.0.1", "root", "user123", "pos");
                                    $query = $link->query("SELECT * FROM cluster_result GROUP BY cluster ORDER BY cluster ASC");
                                    while ($row = $query->fetch_assoc()) {  ?>
                                        <option  value='<?php echo $row['phone']; ?>'><?php echo $row['cluster']; ?></option>
                                        <?php } ?>
                                </select>

                            </div>

                            <div class="form-group">
                                <button type="submit" name="add" class="btn btn-success btn-flat">
                                    <i class="fa fa-paper-plane"></i> Kirim
                                </button>
                                <button type="reset" class="btn btn-secondary btn-danger"><i class="fa fa-ban"></i> Reset</button>
                            </div>
                        </form>

code di controller

SMS_Marketing.php

public function sendSMS()
    {
        $post = $this->input->post(null, TRUE);
        if (isset($_POST['add'])) {
            $email_api = urlencode("rika.sisfountan@gmail.com");
            $passkey_api = urlencode("rk123123");
            $no_hp_tujuan = urlencode($_POST["recipient"]);

            $isi_pesan = urlencode($_POST["message"]);

            $url = "https://reguler.medansms.co.id/sms_api.php?action=kirim_sms&email=" . $email_api . "&passkey=" . $passkey_api . "&no_tujuan=" . $no_hp_tujuan . "&pesan=" . $isi_pesan ;
            $result = file_get_contents($url);
            $data = explode("~~~", $result);

            $this->SMS_Marketing_m->add($post);
            if ($data[0] == 1) {

                echo "<script>
            alert('pesan berhasil terkirim');
            ";
                echo "window.location='" . site_url('sms_marketing') .
                    "';
                </script>";
            } else {
                echo "<script>
            alert('pesan gagal terkirim');
            ";
            }
        }

    }

avatar rikanugraha
@rikanugraha

1 Kontribusi 0 Poin

Dipost 3 tahun yang lalu

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban