Я получил ошибку от онлайн-заставки, но в localhost не появляется.
Ошибка от онлайн-заставки
Severity: error --> Exception:
Call to a member function send_notification() on null controllers/Admin.php 112
Я хочу использовать этот код для отправки сообщений на мойклиенты.
Это контроллер Admin.php.
function notification($param1 = '', $param2 = '')
{
if ($param1 == 'create')
{
$notification_code = $this->crud_model->create_notification();
$check_notification_to_send = $this->input->post('check_notification');
if ($check_notification_to_send == 1) {
$data['title'] = $this->input->post('title');
$customers = $this->db->get('customer')->result_array();
$date = date("d M,Y");
$message = $data['title'] . ' ';
$message .= get_phrase('for more details please login to your acc'). ' ';
$message .= get_phrase('published on') . ' ' . $date;
foreach($customers as $row) {
$reciever_phone = $row['phone'];
//This is the line 112 on which error originate
$this->notification_model->send_notification($message , $reciever_phone);
}
}
}
}
Это модель уведомлений.
function send_notification($message = '' , $reciever_phone = '') {
set_time_limit (0);
require_once(APPPATH . 'libraries/twilio_library/Twilio.php');
$accnt_sid = $this->db->get_where('settings', array('type' => 'accnt_sid'))->row()->description;
$auth_token = $this->db->get_where('settings', array('type' => 'auth_token'))->row()->description;
$client = new Services_Twilio($accnt_sid, $auth_token);
$client->account->messages->create(array(
'To' => $reciever_phone,
'From' => $this->db->get_where('settings', array('type' => 'sender_phone_number'))->row()->description,
'Body' => $message
));
}
Это форма в каталоге View
<div class="col-sm-8">
<input required="" type="text" class="form-control" name="title">
</div>
<div class="form-group has-warning">
<label class="col-sm-3 control-label"><i class="fa fa-bell-o"></i><?php echo get_phrase('send_sms');?></label>
<div class="col-sm-5">
<select required="" class="form-control" name="check_notification">
<option value=""><?php echo get_phrase('select');?></option>
<option value="1"><?php echo get_phrase('yes');?></option>
<option value="2"><?php echo get_phrase('no');?></option>
</select>
</div>
</div>