twilio 操作中的查询参数 url

Query parameter in twilio action url

我正在尝试通过 twilio 的记录动词操作传递数据 url。当有两个或多个查询字符串参数时失败,但只有一个时成功。

成功:

var response = '<Response><Say>STUFF TO SAY</Say><Pause length="1"/><Record maxLength="3600" timeout="30" action="/service/training/call/recording?test1=test&test2=test"></Record></Response>';

失败:

  var response = '<Response><Say>STUFF TO SAY</Say><Pause length="1"/><Record maxLength="3600" timeout="30" action="/service/training/call/recording?test1=test"></Record></Response>';

错误:

Error on line 1 of document  : The reference to entity "test2" must end with the ';' delimiter. 

有什么方法可以通过查询字符串传递数据,还是必须求助于使用 url 参数? "/service/training/call/recording/test/test

Twilio 支持回复了我。这是他们的回应。

解决方法是将代码中的“&”替换为有效的 XML 替换 -“&”。所以你的 TwiML 看起来像这样:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Say>STUFF TO SAY</Say>
  <Pause length="1"/>
  <Record maxLength="3600" timeout="30" action="/service/training/call/recording?test1=test&amp;test2=test">
  </Record>
</Response>