我已经实现了测试twilio sms应用程序.我从https://github.com/benedmunds/CodeIgniter-Twilio下载了三个文件
我在twilio.php文件中使用了我的account_sid,auth_token,该文件位于config文件夹中.我在该文件中也使用了'from'数字作为+15005550006.
我在控制器中使用了以下代码
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Twiliosms extends TL_Controller {
function __construct()
{
parent::__construct();
}
function index()
{
$this->load->library('twilio');
$from = '+15005550006';
$to = '+91xxxxxxxxxx';
$message = 'This is a test...';
$response = $this->twilio->sms($from, $to, $message);
//echo "<pre>";print_r($response);echo "</pre>";
if($response->IsError)
echo 'Error: ' . $response->ErrorMessage;
else
//echo 'Sent message to ' . $to;
echo 'Sent message';
}
}
Run Code Online (Sandbox Code Playgroud)
现在,当我在浏览器中运行控制器文件(不在我的机器中但在服务器中)时,它会成功运行并显示"已发送消息".
但没有收到短信.请帮忙.