【问题标题】:Twilio Receiving SMS codeigniterTwilio 接收短信代码点火器
【发布时间】:2016-04-01 08:15:58
【问题描述】:

您好,我正在使用 twilio 发送和接收来自我的客户的 SMS。发送短信工作正常。

收到短信后,我想将fromBody 保存到我的数据库中。它不起作用。这是我的代码。

控制器

function  receive(){
    $post_data['from']       =  $this->input->post('From');
    $post_data['body']       =  $this->input->post('Body');

    if($post_data['from'] && $post_data['body']){
        $this->receive->insert_received_message($post_data);
    }

}

型号

function insert_received_message($data){

     $sms['pone_number']    = $data['from'];
     $sms['message_type']   = 2;
     $sms['body']           = $data['body'];

     $results = $this->db->insert('Sms_message', $sms); 
     return $results;
}

我像这样将网址添加到我的号码中

已接收日志中的错误消息

谁能帮我解决这个问题。 TNX。

【问题讨论】:

    标签: php codeigniter twilio sms-gateway twilio-php


    【解决方案1】:

    您的数据未保存到数据库中,请确保您的文件名在您的数组中正确

    控制器

    function receive() {
        $from = $this->input->post('From');
        $body = $this->input->post('Body');
    
        if (isset($from) && isset($body)) { //create your insert array like that
            $sms = array(
                'pone_number' => $from,
                'message_type' => 2,
                'body' => $body
            );
    
            $this->receive->insert_received_message($sms);
        }
    }
    

    型号

    function insert_received_message($data){
    
         $this->db->insert('Sms_message', $data); 
         if($this->db->insert_id()>0)// check last insert id
         {
             return $this->db->insert_id();
         }
         else{
             return FALSE;
         }
    
    }
    

    以下链接还演示了如何与收到的消息进行交互。

    https://www.twilio.com/docs/quickstart/php/sms/replying-to-sms-messages

    【讨论】:

    • 我检查了所有字段名称是否正确。仍然没有收到。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-11
    • 2016-04-10
    • 2020-11-14
    相关资源
    最近更新 更多