如何在twilio codeigniter中使用回调网址

时间:2012-12-27 05:52:41

标签: codeigniter twilio

     $data = array(
                        'From' => $from, 
                        'To' => $to, 
                        'Url' => site_url('dashboard/call2')
            );
     // make call request to Twilio

     try{ 
          $twilio = new TwilioRestClient($account_sid, $account_token);
          $result = $twilio->request('2010-04-01/Accounts/'. $account_sid .'/Calls', 
                    'POST', 
                    $data
                    );
            pr($result);
         }
         catch (Exception $e){
                pr($e);
         }


     public function call2() {
         $this->load->view('response');
     }

这里的响应是视图中的xml文件。 response.xml必须作为回调url调用。 但它显示错误:

XML Parsing Error: XML or text declaration not at start of entity
Location: http://www.website.com/index.php/dashboard/call2
Line Number 1, Column 5:    <?xml version="1.0" encoding="UTF-8"?>

1 个答案:

答案 0 :(得分:1)

<?xml声明之前看起来有前导空格。这将导致无法解析文档。

检查PHP标记之外是否有空格,包括可能在结束?>标记之后。这将显示在XML输出中。