【发布时间】:2017-04-16 09:31:25
【问题描述】:
我正在尝试使用 voiceXML 和 Yahoo Weather API 制作语音天气系统。为了开发我的程序,我正在使用 voxeo evolution。
为了调用 Weather API,我使用带有 srcexpr 的 data vxml 标记,因为我需要一个动态 URL(程序要求用户输入一个城市以检查天气)。
这是我的代码:
<?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.1">
<form id="mainMenu">
<field name="City">
<prompt>
Please, name a spanish city.
</prompt>
<grammar src="city.grammar"/>
</field>
<!-- code taken from the javascript example of the yahoo weather api -->
<script>
<![CDATA[
var callbackFunction = function(data) {
var wind = data.query.results.channel.wind;
alert(wind.chill);
};
]]>
</script>
<data srcexpr="https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where woeid in (select woeid from geo.places where text='"+City+", spain')&callback=callbackFunction"/>
</form>
</vxml>
由于data 标签连接到天气API,程序无法运行,但我不知道为什么。有人知道为什么会失败吗?
【问题讨论】:
标签: api yahoo weather vxml voicexml