【发布时间】:2016-04-25 13:52:20
【问题描述】:
我一直在尝试实现一个从我们发送到 Plivo 的 SMS 中检索数据的函数。 目前在我的网站上,我可以发送短信,检查状态,但我希望用户能够响应这些短信并将这些数据存储到我的数据库中。我followed the documentation here 我有这个控制器:
<?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);
}
}
在示例中,他们使用了 $_REQUEST,但它似乎不适用于 Codeigniter,所以我尝试使用 $this->input->get("From") 但没有成功。 Plivo 收到短信,它写在 Plivo Logs 上,我写了指向这个控制器的 URL。
有什么想法吗?
【问题讨论】:
-
在config.php中设置
$config['allow_get_array'] = TRUE; -
它已经在 True
标签: php codeigniter plivo