遇到PHP错误严重性:注意消息:未定义属性:stdClass::$mms

遇到PHP错误严重性:注意消息:未定义属性:stdClass::$mms,php,codeigniter,undefined,Php,Codeigniter,Undefined,我正在尝试集成textlocal api并在CI中获得信用余额。我成功地做到了,但现在我有了错误 遇到PHP错误严重性:注意消息:未定义 属性:stdClass::$mms文件名:libraries/Textlocal.php行 电话:525 以下是我的文本本地api代码: <?php class Textlocal { const REQUEST_URL = 'https://api.textlocal.in/'; const REQUEST_TIMEOUT =

我正在尝试集成textlocal api并在CI中获得信用余额。我成功地做到了,但现在我有了错误

遇到PHP错误严重性:注意消息:未定义 属性:stdClass::$mms文件名:libraries/Textlocal.php行 电话:525

以下是我的文本本地api代码:

    <?php
class Textlocal
{
    const REQUEST_URL = 'https://api.textlocal.in/';
    const REQUEST_TIMEOUT = 60;
    const REQUEST_HANDLER = 'curl';

    private $username;
    private $hash;
    private $apiKey;

    private $errorReporting = false;

    public $errors = array();
    public $warnings = array();

    public $lastRequest = array();

    function __construct($username, $hash, $apiKey = false)
    {
        $this->username = $username;
        $this->hash = $hash;
        if ($apiKey) {
            $this->apiKey = $apiKey;
        }
    }

    private function _sendRequest($command, $params = array())
    {
        if ($this->apiKey && !empty($this->apiKey)) {
            $params['apiKey'] = $this->apiKey;

        } else {
            $params['hash'] = $this->hash;
        }
        // Create request string
        $params['username'] = $this->username;

        $this->lastRequest = $params;

        if (self::REQUEST_HANDLER == 'curl')
            $rawResponse = $this->_sendRequestCurl($command, $params);
        else throw new Exception('Invalid request handler.');

        $result = json_decode($rawResponse);
        if (isset($result->errors)) {
            if (count($result->errors) > 0) {
                foreach ($result->errors as $error) {
                    switch ($error->code) {
                        default:
                            throw new Exception($error->message);
                    }
                }
            }
        }

        return $result;
    }

    private function _sendRequestCurl($command, $params)
    {

        $url = self::REQUEST_URL . $command . '/';

        // Initialize handle
        $ch = curl_init($url);
        curl_setopt_array($ch, array(
            CURLOPT_POST           => true,
            CURLOPT_POSTFIELDS     => $params,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_TIMEOUT        => self::REQUEST_TIMEOUT
        ));

        $rawResponse = curl_exec($ch);
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        $error = curl_error($ch);
        curl_close($ch);

        if ($rawResponse === false) {
            throw new Exception('Failed to connect to the Textlocal service: ' . $error);
        } elseif ($httpCode != 200) {
            throw new Exception('Bad response from the Textlocal service: HTTP code ' . $httpCode);
        }

        return $rawResponse;
    }

    private function _sendRequestFopen($command, $params)
    {
        throw new Exception('Unsupported transfer method');
    }

    /**
     * Get last request's parameters
     * @return array
     */
    public function getLastRequest()
    {
        return $this->lastRequest;
    }

    public function sendSms($numbers, $message, $sender, $sched = null, $test = false, $receiptURL = null, $custom = null, $optouts = false, $simpleReplyService = false)
    {

        if (!is_array($numbers))
            throw new Exception('Invalid $numbers format. Must be an array');
        if (empty($message))
            throw new Exception('Empty message');
        if (empty($sender))
            throw new Exception('Empty sender name');
        if (!is_null($sched) && !is_numeric($sched))
            throw new Exception('Invalid date format. Use numeric epoch format');

        $params = array(
            'message'       => rawurlencode($message),
            'numbers'       => implode(',', $numbers),
            'sender'        => rawurlencode($sender),
            'schedule_time' => $sched,
            'test'          => $test,
            'receipt_url'   => $receiptURL,
            'custom'        => $custom,
            'optouts'       => $optouts,
            'simple_reply'  => $simpleReplyService
        );

        return $this->_sendRequest('send', $params);
    }

    public function sendSmsGroup($groupId, $message, $sender = null, $sched = null, $test = false, $receiptURL = null, $custom = null, $optouts = false, $simpleReplyService = false)
    {

        if (!is_numeric($groupId))
            throw new Exception('Invalid $groupId format. Must be a numeric group ID');
        if (empty($message))
            throw new Exception('Empty message');
        if (empty($sender))
            throw new Exception('Empty sender name');
        if (!is_null($sched) && !is_numeric($sched))
            throw new Exception('Invalid date format. Use numeric epoch format');

        $params = array(
            'message'       => rawurlencode($message),
            'group_id'      => $groupId,
            'sender'        => rawurlencode($sender),
            'schedule_time' => $sched,
            'test'          => $test,
            'receipt_url'   => $receiptURL,
            'custom'        => $custom,
            'optouts'       => $optouts,
            'simple_reply'  => $simpleReplyService
        );

        return $this->_sendRequest('send', $params);
    }
    public function sendBulkSms($data)
    {
        if (is_array($data)) {
            $data = json_encode($data);

            if (json_last_error() !== JSON_ERROR_NONE) {
                throw new \Exception('Invalid JSON string');
            }
        }

        if (strlen(trim($data)) === 0) {
            throw new \Exception('No data to send');
        }

        return $this->_sendRequest('bulk_json', array(
            'data' => $data,
        ));
    }

    public function sendMms($numbers, $fileSource, $message, $sched = null, $test = false, $optouts = false)
    {

        if (!is_array($numbers))
            throw new Exception('Invalid $numbers format. Must be an array');
        if (empty($message))
            throw new Exception('Empty message');
        if (empty($fileSource))
            throw new Exception('Empty file source');
        if (!is_null($sched) && !is_numeric($sched))
            throw new Exception('Invalid date format. Use numeric epoch format');

        $params = array(
            'message'       => rawurlencode($message),
            'numbers'       => implode(',', $numbers),
            'schedule_time' => $sched,
            'test'          => $test,
            'optouts'       => $optouts
        );

        /** Local file. POST to service */
        if (is_readable($fileSource))
            $params['file'] = '@' . $fileSource;
        else $params['url'] = $fileSource;

        return $this->_sendRequest('send_mms', $params);
    }

    public function sendMmsGroup($groupId, $fileSource, $message, $sched = null, $test = false, $optouts = false)
    {

        if (!is_numeric($groupId))
            throw new Exception('Invalid $groupId format. Must be a numeric group ID');
        if (empty($message))
            throw new Exception('Empty message');
        if (empty($fileSource))
            throw new Exception('Empty file source');
        if (!is_null($sched) && !is_numeric($sched))
            throw new Exception('Invalid date format. Use numeric epoch format');

        $params = array(
            'message'       => rawurlencode($message),
            'group_id'      => $groupId,
            'schedule_time' => $sched,
            'test'          => $test,
            'optouts'       => $optouts
        );

        /** Local file. POST to service */
        if (is_readable($fileSource))
            $params['file'] = '@' . $fileSource;
        else $params['url'] = $fileSource;

        return $this->_sendRequest('send_mms', $params);
    }

    /**
     *Returns reseller customer's ID's
     * @return array
     **/

    public function getUsers()
    {
        return $this->_sendRequest('get_users');
    }
    public function transferCredits($user, $credits)
    {

        if (!is_numeric($credits))
            throw new Exception('Invalid credits format');
        if (!is_numeric($user))
            throw new Exception('Invalid user');
        if (empty($user))
            throw new Exception('No user specified');
        if (empty($credits))
            throw new Exception('No credits specified');

        if (is_int($user)) {
            $params = array(
                'user_id' => $user,
                'credits' => $credits
            );
        } else {
            $params = array(
                'user_email' => rawurlencode($user),
                'credits'    => $credits
            );
        }

        return $this->_sendRequest('transfer_credits', $params);
    }

    /**Get templates from an account **/

    public function getTemplates()
    {
        return $this->_sendRequest('get_templates');
    }

    public function checkKeyword($keyword)
    {

        $params = array('keyword' => $keyword);
        return $this->_sendRequest('check_keyword', $params);
    }

    public function createGroup($name)
    {
        $params = array('name' => $name);
        return $this->_sendRequest('create_group', $params);
    }

    public function getContacts($groupId, $limit, $startPos = 0)
    {

        if (!is_numeric($groupId))
            throw new Exception('Invalid $groupId format. Must be a numeric group ID');
        if (!is_numeric($startPos) || $startPos < 0)
            throw new Exception('Invalid $startPos format. Must be a numeric start position, 0 or above');
        if (!is_numeric($limit) || $limit < 1)
            throw new Exception('Invalid $limit format. Must be a numeric limit value, 1 or above');

        $params = array(
            'group_id' => $groupId,
            'start'    => $startPos,
            'limit'    => $limit
        );
        return $this->_sendRequest('get_contacts', $params);
    }

    public function createContacts($numbers, $groupid = '5')
    {
        $params = array("group_id" => $groupid);

        if (is_array($numbers)) {
            $params['numbers'] = implode(',', $numbers);
        } else {
            $params['numbers'] = $numbers;
        }

        return $this->_sendRequest('create_contacts', $params);
    }

    function createContactsBulk($contacts, $groupid = '5')
    {
        // JSON & URL-encode array
        $contacts = urlencode(json_encode($contacts));

        $params = array
        ("group_id" => $groupid, "contacts" => $contacts);
        return $this->_sendRequest('create_contacts_bulk', $params);
    }

    public function getGroups()
    {
        return $this->_sendRequest('get_groups');
    }

    public function getMessageStatus($messageid)
    {
        $params = array("message_id" => $messageid);
        return $this->_sendRequest('status_message', $params);
    }

    public function getBatchStatus($batchid)
    {
        $params = array("batch_id" => $batchid);
        return $this->_sendRequest('status_batch', $params);
    }

    public function getSenderNames()
    {
        return $this->_sendRequest('get_sender_names');
    }
    public function getInboxes()
    {
        return $this->_sendRequest('get_inboxes');
    }

    public function getBalance()
    {
        $result = $this->_sendRequest('balance');
        return array('sms' => $result->balance->sms, 'mms' => $result->balance->mms);
    }

    public function getMessages($inbox)
    {
        if (!isset($inbox)) return false;
        $options = array('inbox_id' => $inbox);
        return $this->_sendRequest('get_messages', $options);
    }

    public function cancelScheduledMessage($id)
    {
        if (!isset($id)) return false;
        $options = array('sent_id' => $id);
        return $this->_sendRequest('cancel_scheduled', $options);
    }

    public function getScheduledMessages()
    {
        return $this->_sendRequest('get_scheduled');
    }
    public function deleteContact($number, $groupid = 5)
    {
        if (!isset($number)) return false;
        $options = array('number' => $number, 'group_id' => $groupid);
        return $this->_sendRequest('delete_contact', $options);
    }
    public function deleteGroup($groupid)
    {
        $options = array('group_id' => $groupid);
        return $this->_sendRequest('delete_group', $options);
    }
    public function getSingleMessageHistory($start, $limit, $min_time, $max_time)
    {
        return $this->getHistory('get_history_single', $start, $limit, $min_time, $max_time);
    }

    public function getAPIMessageHistory($start, $limit, $min_time, $max_time)
    {
        return $this->getHistory('get_history_api', $start, $limit, $min_time, $max_time);
    }

    public function getEmailToSMSHistory($start, $limit, $min_time, $max_time)
    {
        return $this->getHistory('get_history_email', $start, $limit, $min_time, $max_time);
    }
    public function getGroupMessageHistory($start, $limit, $min_time, $max_time)
    {
        return $this->getHistory('get_history_group', $start, $limit, $min_time, $max_time);
    }
    private function getHistory($type, $start, $limit, $min_time, $max_time)
    {
        if (!isset($start) || !isset($limit) || !isset($min_time) || !isset($max_time)) return false;
        $options = array('start' => $start, 'limit' => $limit, 'min_time' => $min_time, 'max_time' => $max_time);
        return $this->_sendRequest($type, $options);
    }

    public function getSurveys()
    {
        return $this->_sendRequest('get_surveys');
    }
    public function getSurveyDetails()
    {
        $options = array('survey_id' => $surveyid);
        return $this->_sendRequest('get_survey_details');
    }
    public function getSurveyResults($surveyid, $start, $end)
    {
        $options = array('survey_id' => $surveyid, 'start_date' => $start, 'end_date' => $end);
        return $this->_sendRequest('get_surveys', $options);
    }

    public function getOptouts($time = null)
    {
        return $this->_sendRequest('get_optouts');
    }
};

class Contact
{
    var $number;
    var $first_name;
    var $last_name;
    var $custom1;
    var $custom2;
    var $custom3;
    var $groupID;   
    function __construct($number, $firstname = '', $lastname = '', $custom1 = '', $custom2 = '', $custom3 = '')
    {
        $this->number = $number;
        $this->first_name = $firstname;
        $this->last_name = $lastname;
        $this->custom1 = $custom1;
        $this->custom2 = $custom2;
        $this->custom3 = $custom3;
    }
};
if (!function_exists('json_encode')) {
    function json_encode($a = false)
    {
        if (is_null($a)) return 'null';
        if ($a === false) return 'false';
        if ($a === true) return 'true';
        if (is_scalar($a)) {
            if (is_float($a)) {
                // Always use "." for floats.
                return floatval(str_replace(",", ".", strval($a)));
            }

            if (is_string($a)) {
                static $jsonReplaces = array(array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"'), array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'));
                return '"' . str_replace($jsonReplaces[0], $jsonReplaces[1], $a) . '"';
            } else
                return $a;
        }
        $isList = true;
        for ($i = 0, reset($a); $i < count($a); $i++, next($a)) {
            if (key($a) !== $i) {
                $isList = false;
                break;
            }
        }
        $result = array();
        if ($isList) {
            foreach ($a as $v) $result[] = json_encode($v);
            return '[' . join(',', $result) . ']';
        } else {
            foreach ($a as $k => $v) $result[] = json_encode($k) . ':' . json_encode($v);
            return '{' . join(',', $result) . '}';
        }
    }
}


And Controller

    <?php
    defined('BASEPATH') OR exit('No direct script access allowed');
    class Short_message_service extends CI_Controller { 
        public function __construct() {
        parent::__construct(); 

        $this->load->model('Common_model'); 
        $this->load->model('Authentication_model');
        $this->load->library('form_validation');
        $this->Common_model->setDefaultTimezone();

        $this->load->library('setupfile');

        if (!$this->session->has_userdata('user_id')) {
            redirect('Authentication/index');
        }

        if (!$this->session->has_userdata('outlet_id')) {
            $this->session->set_flashdata('exception_2', lang('please_click_green_button'));

            $this->session->set_userdata("clicked_controller", $this->uri->segment(1));
            $this->session->set_userdata("clicked_method", $this->uri->segment(2));
            redirect('Outlet/outlets');
        }

        $getAccessURL = $this->uri->segment(1);
        if (!in_array($getAccessURL, $this->session->userdata('menu_access'))) {
            redirect('Authentication/userProfile');
        }
    }

    public function send(){
        $this->setupfile->send("123455", "Hello there this is message");
    }

    public function smsService(){ 
        $data = array(); 
        $data['main_content'] = $this->load->view('shortMessageService/smsService', $data, TRUE);
        $this->load->view('userHome', $data);
    }

    public function sendSMS($type=''){
        $data = array(); 
        $data['type'] = $type;

        $credentials = $this->Common_model->getDataById(1, 'tbl_sms_settings'); 
        require(APPPATH.'libraries/Textlocal.php');

        $textlocal = new Textlocal($credentials->email_address, $credentials->password);

        try {
            $result = $textlocal->getBalance(); 
           $data['balance'] = $result['sms'];
        } catch (Exception $e) {
            $data['balance'] = "<span>Connection is not properly established</span>";
        } 

        $today = date('Y-m-d');
        if ($this->input->post('submit')) { 

            if (empty($credentials->email_address)) {
                $this->session->set_flashdata('exception_2', 'Please configure SMS first');
                redirect('Short_message_service/smsService');
            }

            $this->form_validation->set_rules('outlet_name', lang('outlet_name'), 'required|max_length[50]');
            $this->form_validation->set_rules('message', lang('message'), 'required|max_length[200]');
            if ($type == "Test") {
                $this->form_validation->set_rules('number',lang('number'), 'required|max_length[50]'); 
            }
            if ($this->form_validation->run() == TRUE) { 

                $sender = $this->input->post($this->security->xss_clean('outlet_name'));
                $message = $this->input->post($this->security->xss_clean('message')); 
                $numbers = array($this->input->post($this->security->xss_clean('number')));  

                if ($type == 'test') { 
                    try {
                        $result = $textlocal->getBalance(); 
                        $data['balance'] = $result['sms'];
                    } catch (Exception $e) { 
                        $this->session->set_flashdata('exception', 'Connection is not properly established');
                        redirect('Short_message_service/smsService');
                    }  

                    try {
                        $result = $textlocal->sendSms($numbers, $message, $sender); 
                        $this->session->set_flashdata('exception', 'SMS has been sent successfully!');
                    } catch (Exception $e) {
                        die('Error: ' . $e->getMessage());
                    }
                }else{ 

                    if ($type == 'birthday') {
                        $sms_count = $this->db->query("select * from tbl_customers where `date_of_birth`='". $today."' and concat('',phone * 1) = phone")->result();
                    }elseif ($type =='anniversary') {
                        $sms_count = $this->db->query("select * from tbl_customers where `date_of_anniversary`='". $today."' and concat('',phone * 1) = phone")->result();
                    }elseif ($type =='custom') {
                        $sms_count = $this->db->query("select * from tbl_customers where concat('',phone * 1) = phone")->result();
                    }  

                    if (empty($sms_count)) {
                        $this->session->set_flashdata('exception_2', 'No customer has birthday or anniverysary today or no customer found with valid phone number!');
                        redirect('Short_message_service/smsService');
                    }

                    try {
                        $result = $textlocal->getBalance(); 
                        $data['balance'] = $result['sms'];
                    } catch (Exception $e) { 
                        $this->session->set_flashdata('exception_2', 'Connection is not properly established');
                        redirect('Short_message_service/smsService');
                    }  

                    foreach ($sms_count as $value) {  
                        try {
                            $result = $textlocal->sendSms($numbers, $message, $sender); 
                            $this->session->set_flashdata('exception', 'SMS has been sent successfully!');
                        } catch (Exception $e) {
                            $this->session->set_flashdata('exception_2', 'Connection is not properly established!');
                            die('Error: ' . $e->getMessage());
                        }
                    }
                } 

                redirect('Short_message_service/smsService');
            } else {
                $day = '';
                $outlet_name = $this->session->userdata('outlet_name');

                if ($type == 'birthday') {
                    $day = "Birthday";
                }elseif ($type =='anniversary') {
                    $day = "Anniversary";
                }  

                if ($type == 'birthday' || $type == 'anniversary') {
                    $data['message'] = "Wishing you Happy $day from $outlet_name. Please come to our restaurant and enjoy discount in your special day.";
                }else{
                    $data['message'] = "";
                } 

                $data['outlet_name'] = $outlet_name;

                $today = date('Y-m-d');

                if ($type == 'birthday') {
                    $data['sms_count'] = $this->db->query("select * from tbl_customers where `date_of_birth`='". $today."' and concat('',phone * 1) = phone")->result();
                }elseif ($type =='anniversary') {
                    $data['sms_count'] = $this->db->query("select * from tbl_customers where `date_of_anniversary`='". $today."' and concat('',phone * 1) = phone")->result();
                }elseif($type =='custom'){
                    $data['sms_count'] = $this->db->query("select * from tbl_customers where concat('',phone * 1) = phone")->result();
                }    

                if ($type == 'balance') {
                    $data['main_content'] = $this->load->view('shortMessageService/checkBalance', $data, TRUE); 
                }else{ 
                    $data['main_content'] = $this->load->view('shortMessageService/sendSMS', $data, TRUE);
                } 
                $this->load->view('userHome', $data); 
            }
        }else{
            $day = '';
            $outlet_name = $this->session->userdata('outlet_name');

            if ($type == 'birthday') {
                $day = "Birthday";
            }elseif ($type =='anniversary') {
                $day = "Anniversary";
            }  

            if ($type == 'birthday' || $type == 'anniversary') {
                $data['message'] = "Wishing you Happy $day from $outlet_name. Please come to our restaurant and enjoy discount in your special day.";
            }else{
                $data['message'] = "";
            } 

            $data['outlet_name'] = $outlet_name;

            $today = date('Y-m-d');

            if ($type == 'birthday') {
                $data['sms_count'] = $this->db->query("select * from tbl_customers where `date_of_birth`='". $today."' and concat('',phone * 1) = phone")->result();
            }elseif ($type =='anniversary') {
                $data['sms_count'] = $this->db->query("select * from tbl_customers where `date_of_anniversary`='". $today."' and concat('',phone * 1) = phone")->result();
            }elseif($type =='custom'){
                $data['sms_count'] = $this->db->query("select * from tbl_customers where concat('',phone * 1) = phone")->result();
            }    

            if ($type == 'balance') {
                $data['main_content'] = $this->load->view('shortMessageService/checkBalance', $data, TRUE); 
            }else{ 
                $data['main_content'] = $this->load->view('shortMessageService/sendSMS', $data, TRUE);
            } 
            $this->load->view('userHome', $data); 
        }
    } 

}

第525行是什么?是否在函数getBalance()中,是否尝试了
echo';打印(结果);死亡?getBalance()方法的响应是什么??并检查$this->_sendRequest('balance');?的响应??