0

I've been trying to implement a function that retrieve the data from a SMS we send to Plivo. Currently in my website, I can send a SMS, check the status, but I want users to be able to respond to these SMS and store these data into my database. I followed the documentation here I have this controller :

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Receive extends CI_Controller {

    function __construct()
    {
        parent::__construct();

        $this->load->model('receive_model');
    }

    public function index()
    {
        // Sender's phone numer
        $from_number = $this->input->get("From");
        // Receiver's phone number - Plivo number
        $to_number = $this->input->get("To");
        // The SMS text message which was received
        $text = $this->input->get("Text");
        // Output the text which was received to the log file.
        // error_log("Message received - From: ".$from_number.", To: ".$to_number. ", Text: ".$text);
        $arr = array("from" => $from_number, "to" => $to_number, "text" => $text);
        $this->receive_model->add($arr);
    }

}

In the example, they use $_REQUEST but it seems that it doesn't work on Codeigniter, so I tried with $this->input->get("From") but no success. Plivo receives the SMS, it's written Received on Plivo Logs, and I wrote the URL that points to this controller.

Any idea ?

Komarzer
  • 629
  • 3
  • 7
  • 20

1 Answers1

0

You can follow the below steps to debug this issue:

  1. Check the Message URL of the Plivo application if it is set properly with your number.
  2. Set Message Method as POST. It is relevant to CodeIgniter.
  3. Enable CI error log on config/config.php and put the below code into your controller method to log all requests.

log_message('error', "Plivo Responses: " . print_r($_REQUEST, true) ."\n");

  1. Receive a test message (or you can run a simple HTML form by adding SMS fields).
  2. Check your CI log.
rubai
  • 81
  • 1
  • 2