我正在尝试使用以下代码访问Twilio Rest API,以检索指定日期范围内我的twilio号码的来电列表。
https://www.twilio.com/docs/api/rest/call
<cfhttp url="https://api.twilio.com/2010-04-01/Accounts/xxxxxxxxxxxxxxxxx/Calls" method="get" resolveurl="no" username="xxxxxx" password="xxxxx1">
<cfhttpparam name="To" type="url" value="myphone">
<cfhttpparam name="StartTime>=" type="url" value="2015-05-01">
<cfhttpparam name="StartTime<" type="url" value="2015-06-01">
</cfhttp>
当我尝试连接上述内容时,我在coldfusion中出现“连接”错误。它不喜欢“&gt;”。我也试过把StartTime&gt;在变量上执行urlencodedformat(),但它没有给出所需的结果。
当我查询个人日时,它可以正常工作。
<cfhttp url="https://api.twilio.com/2010-04-01/Accounts/xxxxxxxxxxxxxxxxx/Calls" method="get" resolveurl="no" username="xxxxxx" password="xxxxx1">
<cfhttpparam name="To" type="url" value="myphone">
<cfhttpparam name="StartTime" type="url" value="2015-05-01">
</cfhttp>
根据Twilio代码示例(我引用PHP示例),变量名称可以是StartTime&gt;,StartTime&gt; =,StartTime&lt;,StartTime&lt; =。
答案 0 :(得分:1)
在您的代码中,您正在调用&#34; StartTime&#34;
<cfhttp url="https://api.twilio.com/2010-04-01/Accounts/xxxxxxxxxxxxxxxxx/Calls" method="get" resolveurl="no" username="xxxxxx" password="xxxxx1">
<cfhttpparam name="To" type="url" value="myphone">
<cfhttpparam name="StartTime>=" type="url" value="2015-05-01">
<cfhttpparam name="StartTime<" type="url" value="2015-06-01">
</cfhttp>
根据https://www.twilio.com/docs/api/rest/call,您应该使用 StartTime &amp;的结束时间即可。我可以使用以下代码转储httpResponse: -
<cfhttp url="https://api.twilio.com/2010-04-01/Accounts/xxxxxxxxxxxxxxxxx/Calls" method="get" resolveurl="no" username="xxxxxx" password="xxxxx1" result="httpResponse">
<cfhttpparam name="To" type="url" value="myphone">
<cfhttpparam name="StartTime" type="url" value="2015-05-01">
<cfhttpparam name="EndTime" type="url" value="2015-06-01">
</cfhttp>
<cfdump var="#httpResponse#" label="httpResponse">
此外,https://www.twilio.com需要两个SSL证书。您需要将这些导入到密钥库。