0
我試圖在我的Laravel應用程序中接收傳真,但似乎無法正確格式化XML。爲Twilio響應格式化XML
由於我第一次設置這個,我試圖模仿Twilio快速入門指南中的基本操作。
使用Twilio儀表盤,我已經設置myapp.com/fax/sent的網絡掛接地址時,接收到的傳真試圖發送通知:
public function sent()
{
$twimlResponse = new SimpleXMLElement("<Response></Response>");
$recieveEl = $twimlResponse->addChild('Receive');
$receiveEl->addAttribute('action', '/fax/received');
return response($twimlResponse->asXML())
->header('Content-Type', 'text/xml');
}
,我從Twilio得到的錯誤基本上是空的:
Error 12100 Document parse failure
Twilio錯誤請求檢查器顯示沒有頭或身體。
我也試圖在地方返回構建XML的一個硬編碼的視圖文件:
視圖fax.sent:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Receive action="/fax/received" />
</Response>
,然後改變了發送功能:
public function sent()
{
return View::make('fax.sent')->header('Content-Type', 'text/xml');
}
這將返回相同的錯誤消息。
當你去'myapp.com /傳真/發送'你會得到您的預期的XML與正確的內容類型? – Andy
@Andy是的,我做 – retrograde
我不會認爲這很重要,但在xml頭文件中嘗試使用'utf-8'而不是'UTF-8' – Andy