使用Twilio API使用Codeigniter向数据库插入新的调用方

使用Twilio API使用Codeigniter向数据库插入新的调用方,codeigniter,twilio,Codeigniter,Twilio,下面是在我的控制器中接收所有来电的功能 public function call_incoming() { $blocklist = $this->call_log_model->get_blocklist($_REQUEST['From']); $tenantNum = $this->call_log_model->get_called_tenant($_REQUEST['From']); $tenantInfoByNumber = $this-

下面是在我的控制器中接收所有来电的功能

public function call_incoming()
{
    $blocklist = $this->call_log_model->get_blocklist($_REQUEST['From']);
    $tenantNum = $this->call_log_model->get_called_tenant($_REQUEST['From']);
    $tenantInfoByNumber = $this->account_model->getTenantInfoByNumber($tenantNum->to_tenant);
    $officeStatus = $this->check_office_hours($tenantInfoByNumber->start_office_hours, $tenantInfoByNumber->end_office_hours);
    $calldisposition = $this->calldisp_model->get_call_disposition($tenantInfoByNumber->user_id);

    $response = new Services_Twilio_Twiml;

    if($blocklist == 0)
    {
        if($officeStatus == "open")
        {
            if($_POST['Called'] != AGENTPOOL_NUM)
            {
                $data = array(
                    'caller'=>$_REQUEST['From'],
                    'to_tenant'=>$_POST['Called'],
                    'date_created'=>date('Y-m-d H:i:s')
                );
                $this->call_log_model->insert_caller_to_tenant($data);

                $dial = $response->dial(NULL, array('callerId' => $_REQUEST['From']));
                $dial->number(AGENTPOOL_NUM);
                print $response;
            }
            else
            {
                $gather = $response->gather(array('numDigits' => 1, 'action'=>HTTP_BASE_URL.'agent/call_controls/call_incoming_pressed', 'timeout'=>'5' , 'method'=>'POST'));
                $ctr = 1;
                foreach($calldisposition as $val )
                {
                    $gather->say('To go to '.$val->disposition_name.', press '.$ctr, array('voice' => 'alice'));
                    $gather->pause("");
                    $ctr++;
                }
                print $response;
            }
        }
        else
        {
            $response->say('Thank you for calling. Please be advise that our office hours is from '.$tenantInfoByNumber->start_office_hours.' to '.$tenantInfoByNumber->end_office_hours);
            $response->hangup();
            print $response;
        }

    }
    else
    {
        $response->say('This number is blocked. Goodbye!');
        $response->hangup();
        print $response;
    }
} 
请告知我是否需要发布模型

下面是每次未知号码呼叫时发生的情况,呼叫方将听到应用程序错误已发生错误消息,当检查Twilio控制台时,它给我的错误是

遇到一个PHP错误

严重性:注意
消息:正在尝试获取非对象的属性
文件名:agent/Call_controls.php
电话号码:357

请注意,只有当来电者是数据库中尚未出现的号码时,才会发生此错误。当电话来自已保存在数据库中的号码时,此代码有效

谢谢你的帮助

if($tenantNum) { 
  $tenantInfoByNumber = $this->account_model->getTenantInfoByNumber($tenantNum->to_t‌​enant); 
} else { 
  $tenantInfoByNumber = ""; // fill this in with relevant fill data 
}

这应该可以解决您的问题,因为没有返回TenantNum,也没有数据,所以。

您能告诉我们第357行是什么吗?它是
$tenantInfoByNumber=$This->account\u model->getTenantInfoByNumber($TenantNum->to\u tenant)
如果($tenantNum){$tenantInfoByNumber=$this->account\u model->getTenantInfoByNumber($tenantNum->to\u tenant)}否则{$tenantInfoByNumber=“”;//用相关的填充数据填充此项}
将尝试此操作,我将在几分钟后给出反馈,请发布答案解决我的问题。。。