0
我正在尝试使用voiceXML和Yahoo Weather API制作语音天气系统。为了开发我的程序,我正在使用voxeo进化。从VoiceXML调用Yahoo Weather API
要调用Weather API,我使用的data
vxml标记与srcexpr
,因为我需要一个动态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,但我不知道为什么。做一个人知道为什么失败?