Daniyar's Tech blog
A nice way to document IT ideas!
Search This Blog
Monday, January 2, 2012
Yahoo or Google weather on your cisco IP Phone
<%@ Language=JavaScript%> <% Response.ContentType = "text/xml"; Response.Write("
\r\n"); Response.Write("
Weather forecast for Geneva
\r\n"); Response.Write("
\r\n"); Response.Write("
"); try { var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); xmlhttp.Open("GET", "http://weather.yahooapis.com/forecastrss?w=782538&u=c", false); xmlhttp.Send(); var xmldata = ""; xDoc = new ActiveXObject("MSXML2.DOMDocument") xDoc.async = false; xDoc.loadXML(xmlhttp.responseText); var node = xDoc.selectSingleNode("//rss/channel/item/yweather:forecast"); xmldata = node.attributes.getNamedItem("text").value; Response.Write(xmldata);Response.Write(".\r\n"); xmldata = node.attributes.getNamedItem("low").value; Response.Write("Low temperature: "); Response.Write(xmldata);Response.Write("°\r\n"); xmldata = node.attributes.getNamedItem("high").value; Response.Write("High temperature: "); Response.Write(xmldata);Response.Write("°\r\n"); } catch(err) { Response.Write("Yahoo Service Error\r" + err.description + "\r" + err.number); } Response.Write("
\r\n"); Response.Write ("
Exit
SoftKey:Exit
3
\r\n"); Response.Write("
\r\n"); Response.End(); Session.Abandon(); %> and Google: <%@ Language=JavaScript%> <% Response.ContentType = "text/xml"; Response.Write("
\r\n"); Response.Write("
Weather in Geneva
\r\n"); Response.Write("
\r\n"); Response.Write("
"); try { var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); xmlhttp.Open("GET", "http://www.google.com/ig/api?weather=Geneva,Switzerland&hl=en", false); xmlhttp.Send(); var xmldata = ""; xDoc = new ActiveXObject("MSXML2.DOMDocument") xDoc.async = false; xDoc.loadXML(xmlhttp.responseText); var node = xDoc.selectSingleNode("//xml_api_reply/weather/current_conditions/temp_c"); xmldata = node.attributes.getNamedItem("data").value; Response.Write("Temperature: ");Response.Write(xmldata);Response.Write("°\r\n"); node = xDoc.selectSingleNode("//xml_api_reply/weather/current_conditions/condition"); xmldata = node.attributes.getNamedItem("data").value; Response.Write(xmldata); Response.Write("\r\n"); node = xDoc.selectSingleNode("//xml_api_reply/weather/current_conditions/humidity"); xmldata = node.attributes.getNamedItem("data").value; Response.Write(xmldata); Response.Write("\r\n"); } catch(err) { Response.Write("Google Service Error\r" + err.description + "\r" + err.number); } Response.Write("
\r\n"); Response.Write ("
Exit
SoftKey:Exit
3
\r\n"); Response.Write("
\r\n"); Response.End(); Session.Abandon(); %>
1 comment:
albina N muro
said...
This comment has been removed by a blog administrator.
July 2, 2013 at 2:33 PM
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
1 comment:
Post a Comment