Hi Ira,
You can certainly call any API from scriptr.io and read the response. I wrote a sample for you below using a third party weather service (openweathermap.org). If you want to use the same service, make sure to replace the API Key (appid parameter) with your own API Key which you can get when you create an account.
var lat = 35;
var lon = 139;
var weatherApi = "http://api.openweathermap.org/data/2.5/weather?appid=XXXXXXXXXXXXXXXXXXX&lat=" + lat + "&lon=" + lon;
var http = require("http");
var response = http.request({
url : weatherApi
});
if (response.status == "200") {
var weatherInfo = JSON.parse(response.body);
return weatherInfo;
} else {
return "Ooops, there was a problem retrieving weather information!";
}
I hope this helps.
Julien
It certainly does, thank you.
I tried the sample in the Scriptr documentation under the section ”what can a script do?” , but it generated errors. Your suggestion of openweathermap.org is exactly what I needed.
Thanks again, Ira
You’re right, the third party used to get weather info modified their API and now it requires to be called over HTTPS only.
Thanks for informing us!
Julien