Jump to content

where found ready made scripts get yahoo weather


lse123

Recommended Posts

I am trying get current weather for my city Polis, Cyprusbut I do not make it, in the<body><div id="d"></div>I get nothing in test page, can you help...you may download files.js from test page below:http://developer.yahoo.com/weather/ // here format of rss xmlhttp://weather.yahooapis.com/forecastrss?p=CYXX0009&u=ctest pagehttp://www.paphoscarhire.mobi/weather/weather-polis.php You may get help from:http://www.w3schools.com/dom/dom_nodes_get.asp javascript permits connections from yahoo weather (external servers)?where found ready made scripts get yahoo weather?

Link to comment
Share on other sites

You might find some example code on their developers forums. Basically, you need to make an HTTP request to Yahoo first, with the WOEID of the location in question, and the (optional) requested degrees in F or C as parameters in the URL. If the request comes back successful, you will then have an XML file with the RSS feed information, which you will then have to get the information out of, and parse into your page. (this is all in the link that you gave us by the way).I think your biggest obstacles will not be Yahoo, but coding your page properly. The HTML already looks a "little" funky, so make sure you have a handle on the basics first (HTML/CSS) and then go through the Javascript tutorials, with an eye towards leanring how to use XMLHttpRequest() and then off to learn about parsing XML. Of course that's not say you might not find what you're looking for online, but if you wanted the reward of doing it yourself, well...you have the option. And who doesn't love to learn something new? :)

Link to comment
Share on other sites

sorry, I'm not going to try it or do it for you. Why don't you try what you found and see if it works? You should have more than enough info between Yahoo and W3Schools to get yourself up and running, and for us to assist when you have specific problems and questions.

Link to comment
Share on other sites

If you want to use ajax to load a file on another domain, you need to use a server proxy. You can do that easily with PHP or ASP.The idea is to have Javascript send the request to the PHP page on your same domain, and then have PHP get the remote file, and give it back to Javascript. A PHP script like this will do that, if the server allows it:

<?php$f = trim(isset($_GET['f']) ? $_GET['f'] : '');if ($f != '' && strpos($f, 'http://') === 0){  echo file_get_contents($f);}?>

You would save that file like proxy.php, and then send your request there and tell it what file to load:var url= 'proxy.php?f=' + encodeURIComponent("http://weather.yahooapis.com/forecastrss?p=CYXX0009&u=c");

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...