无法使用twilio将传入消息存储在我的数据库中

时间:2019-07-10 06:44:15

标签: codeigniter twilio twilio-api twilio-php twilio-programmable-chat

我正在使用twilio发送短信。我可以发送短信,但是我不能接收传入的短信,也不能存储在数据库中。当我从客户那里收到短信到我的twilio号码时。我想从数字和正文中获取字段,然后保存到我的数据库中。 在下面的代码中,我给出了代码。请说明问题所在以及需要进行哪些更改以将数据存储在数据库中。

查看代码:

<!--sidebar end-->
<!--main content start-->
<section id="main-content">
    <section class="wrapper site-min-height">
        <!-- page start-->
        <section class="panel panel--colour-orange">
            <header class="panel-heading">
            </header>

            <form role="form" action="patient/receivesmsadd" method="post" style="border: 0px solid #ccc; padding: 0px;">

            <div class="col-md-12" style="padding: 30px 20px 15px 15px;">

            <div class="col-md-6">
                <div class="panel-body-wrapper">
                        <li class="list-group-item" style="border-top: 2px solid #2789D9;">

                            <div class="form-group" style="margin-bottom: 10px">
                            </div>
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <input type="text" placeholder="Appointment id" name="appointment_id" id="appointment_id" class="numeric form-control" maxlength="13" value="<?php echo($_REQUEST['body[0]']); ?>">
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <input type="text" placeholder="Bill Process" name="acceptance" id="acceptance" class="numeric form-control" value="<?php echo($_REQUEST['body[1]']); ?>">
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <input type="text" name="payment_method" placeholder="Payment Method" id="payment_method" class="numeric form-control" value="<?php echo($_REQUEST['body[2]']); ?>">
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <input type="text" name="phone" placeholder="Phone" id="phone" class="numeric form-control" value="<?php echo($_REQUEST['from']); ?>">
                                    </div>
                                </div>
                            </div>
                        </li>
                    </ul>
                </div>

            </div>

        </div>
        <section class="" style="margin-left: 25px;">
            <button type="submit" name="submit" class="btn btn-blue" style="margin-left: 5px;margin-bottom: 30px;">Create</button>
        </section>
        </form>

        </section>
    </section>
</section>

控制器代码:

function receivesmsadd(){
        $data = array();
        $data['appointment_id']        = $this->input->post('appointment_id');
        $data['acceptance']            = $this->input->post('acceptance');
        $data['payment_method']        = $this->input->post('payment_method');
        $data['phone']                 = $this->input->post('phone');

        $this->load->model('patient_model');
        if ($this->patient_model->receivesms($data)) {
            $this->session->set_flashdata('message','Added Successfully');
        } else {
            $this->session->set_flashdata('message','Failed to Added');
        }     
    }

模式代码:

 function receivesms($data) {
        return $this->db->insert('receivesms',$data);
    }

0 个答案:

没有答案