Link to home
Start Free TrialLog in
Avatar of PowerEdgeTech
PowerEdgeTechFlag for United States of America

asked on

Weather API for Website

Ok, so I am trying to put a simple piece of weather information on a website, and I'm trying to use the WeatherBug API:

http://api-portal.earthnetworks.com/package/Bronze

I am running into problems that I found out are related to accessing an XML document from another domain.  

Can someone help me understand how to overcome this "cross-domain" issue and help me with the most basic code required to write the value of the current temperature to a webpage?

I'm most comfortable with JavaScript but can follow VB.NET code too, and I don't have a problem implementing another language (although it should be basic/simple - and no PHP).  Remember, the simplest code possible to accomplish this.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PowerEdgeTech

ASKER

I was just using plain old JavaScript, using XMLHttpRequest().
You need to build a proxy on your server (VB or C#)
The gaold of this proxy is to load the XML for your page, so your page and the proxy reside on the same domain. Instead calling the API from your page, you ask your proxy to call it for you AND return the data to your page.

A good article (don't forget to vote) : https://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_3612-ASP-NET-Proxy-Page-Used-for-Cross-Domain-Requests-from-AJAX-and-JavaScript.html

similar question : https://www.experts-exchange.com/questions/26759864/Jquery-Get-function.html
leakim ... I'm sorry - while I'm sure your method works, I'm not sure that falls in the classification of "simple", so I went with Gary's answer.  With that answer, while I would have appreciated a simple example of code rather than a Wiki link (hence the 'B' grade for only providing the name of the protocol necessary), researching JSONP got me started in the right direction.  I now have basic weather info on the website from WeatherBug.

Thanks.
You give a Grade "B" but you did not answered its question.
I'm 100% sure its question << Are you using jQuery or vanilla js >> was to provide you an example of code...
"I'm 100% sure its question was to provide you an example of code"

Possibly, but I answered his question within 2 minutes, and after 3 days, I figured it wasn't coming.

Don't misunderstand - I did appreciate the answer - it ultimately got me to the solution.
leakim its fine.

I get hundreds of email a day from EE and sometimes the odd one slips thru.
Glad you got it worked out.