Please read the posts in the Announcements section about the current status of Cumulus development now that I have retired

Please read this post before posting

Latest Cumulus release v1.9.4 (build 1099) - Nov 28 2014
Latest Cumulus MX release - v3.0.0 build 3043 Jan 20 2017. See this post for download

Dark Sky API

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderators: daj, TNETWeather

bigmac
Posts: 152
Joined: Wed May 13, 2009 9:35 am
Weather Station: Davis Vantage Pro 2 Wireless
Operating System: Raspbian wheezy
Location: Nr Ilkley, West Yorks, UK
Contact:

Dark Sky API

Postby bigmac » Sun Jan 17, 2016 10:59 pm

Been looking at updating my forecast page as it looks like the free Meteorologica maps have stopped working. Found an app on IOS called Dark Sky and they also do an API (https://developer.forecast.io) to integrate onto your own website. The first 1000 API calls per day are free and then charged at $0.0001 per call after that.
Anyone else using Dark Sky and also how could I limit the number of calls so that if I hit 1000, it wouldn't make any more calls for the day as I can't fund it infinitesimally. Or perhaps someone could also advise how my site could maybe subsidise the cost through advertising?

Lots of thoughts and questions :D

water01
Posts: 1460
Joined: Sat Aug 13, 2011 9:33 am
Weather Station: WH1081
Operating System: Windows 7 64bit HP SP1
Location: Somewhere in the USA
Contact:

Re: Dark Sky API

Postby water01 » Sun Jan 17, 2016 11:33 pm

This Forecast page from Yr,no is free http://www.dmjsystems.co.uk/weather/forecast.php

User avatar
mcrossley
Posts: 5192
Joined: Thu Jan 07, 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Stretch Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Dark Sky API

Postby mcrossley » Mon Jan 18, 2016 9:47 am

bigmac wrote:Been looking at updating my forecast page as it looks like the free Meteorologica maps have stopped working. Found an app on IOS called Dark Sky and they also do an API (https://developer.forecast.io) to integrate onto your own website. The first 1000 API calls per day are free and then charged at $0.0001 per call after that.
Anyone else using Dark Sky and also how could I limit the number of calls so that if I hit 1000, it wouldn't make any more calls for the day as I can't fund it infinitesimally. Or perhaps someone could also advise how my site could maybe subsidise the cost through advertising?

Lots of thoughts and questions :D

If you get your server to fetch the data and add it to the page then you could cache the data locally on your server. You return the cached data unless it is stale (say older than 20 minutes) then the server refreshes from source. This is pretty standard, most of the 'template' scripts do this for Weather Underground etc. as they also have API hit limits.

bigmac
Posts: 152
Joined: Wed May 13, 2009 9:35 am
Weather Station: Davis Vantage Pro 2 Wireless
Operating System: Raspbian wheezy
Location: Nr Ilkley, West Yorks, UK
Contact:

Re: Dark Sky API

Postby bigmac » Mon Jan 18, 2016 9:53 pm

Ok, thanks gents. Food for thought, I will probably be back with more questions at a later date!

AllanG
Posts: 5
Joined: Mon Oct 05, 2009 7:19 am
Weather Station: WeatherDuino Pro2
Operating System: Windows 10 Pro
Location: Prescot, Merseyside

Re: Dark Sky API

Postby AllanG » Sat Jan 23, 2016 4:43 pm

A little off topic, I hope the op will forgive me.

water01 wrote:This Forecast page from Yr,no is free http://www.dmjsystems.co.uk/weather/forecast.php


David, I came across the 10 day forecast available from yr.no a while ago and recently downloaded Henkka's script to use it. I've spent days - literally - trying to get it working and I'm now very close, but one problem obstinately remains... :groan:

On loading the page, my location and co-ordinates (Prescot, Merseyside) appear correctly but the sunrise and sunset times are way out. Apparently sr here is currently at 01:10 and ss 09:30 :lol: :o :o Seems the forecast is correct but "offset" by about 5-6 hours too.

However when I select Prescot from the dropdown list, nothing else changes but the correct times do appear. I thought the problem may be related to my web hosting being located in Denver, US, but completely removing the "server geo-ip" lines of code made no difference (and it seems Just Host don't use them anyway.)

You've obviously modified the script and it's running perfectly. Have you any thoughts about where my problem may be, if so they'd be very gratefully received!

In this location at least, the forecast has proved pretty accurate over most of the last week or so and it seems a really worthwhile addition if I can get the script to behave itself!

Should you want to have a look at the test page, url is http://www.prescotpages.co.uk/Weather_S ... yrtest.php

Allan.

water01
Posts: 1460
Joined: Sat Aug 13, 2011 9:33 am
Weather Station: WH1081
Operating System: Windows 7 64bit HP SP1
Location: Somewhere in the USA
Contact:

Re: Dark Sky API

Postby water01 » Sat Jan 23, 2016 5:29 pm

Have you set your default Timezone correctly in yr_xmlII.php

Code: Select all

$deftz = "Europe/London";


Failing that could I see a copy of your yr_xmlII.php script please.

water01
Posts: 1460
Joined: Sat Aug 13, 2011 9:33 am
Weather Station: WH1081
Operating System: Windows 7 64bit HP SP1
Location: Somewhere in the USA
Contact:

Re: Dark Sky API

Postby water01 » Sat Jan 23, 2016 5:36 pm

OK I think I know what your problem is.

The yr-test.php is meant as a test program with you then loading your co-ordinates.

When you use it in reality you should edit yr_xmlII.php to set your defaults e.g.

Code: Select all

// Units
$useC = 1;      // Use Celsius, else F
$useKMH = 0;      // Use Km/h
$useMPH = 1;      // Use Mph, if both KMH and MPH is zero is default m/s used
$useHPA = 1;      // Use hPa, else inHg
$useMM= 0;      // Use mm, else in

// Timesettings, normal PHP/date-tags used
$datestyle = "d.m.Y";      // Style of short date
$timestyle = "H:i";      // Style of time
$longdate = "d.m.Y H:i";   // Style of long time + date
$deftz = "Europe/London";
$pagename = "forecast.php";

$geonameusr = "xxxxxxxxx"; // IMPORTANT! You need to signup at geonames.org (FREE), put username here

// Cachesettings etc. settings
$qarefetchSeconds = 3600;   // How often it refresh the cache, 3600 recommended
$imgdir = "images/";   // Icons-folder
$jsfolder = "jquery/";
$cssfolder = "css/";
$cachefolder = "/home/dmjsyste/public_html/weather/cache/";
$days = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');

// Default place
$cod = "GB";
$cou = "United Kingdom";
$cit = "Binegar";
$lat = 51.2425;
$lon = -2.5394;


and make sure you have signed up for geonames.org and entered your name in $geonameusr

AllanG
Posts: 5
Joined: Mon Oct 05, 2009 7:19 am
Weather Station: WeatherDuino Pro2
Operating System: Windows 10 Pro
Location: Prescot, Merseyside

Re: Dark Sky API

Postby AllanG » Sat Jan 23, 2016 6:39 pm

Thanks for the suggestions, though I think I've already covered them. "Defaults" section of code is:

Code: Select all

// Units
$useC = 1;      // Use Celsius, else F
$useKMH = 0;      // Use Km/h
$useMPH = 1;      // Use Mph, if both KMH and MPH is zero is default m/s used
$useHPA = 1;      // Use hPa, else inHg
$useMM= 1;      // Use mm, else in

// Timesettings, normal PHP/date-tags used
$datestyle = "d.m.Y";      // Style of short date
$timestyle = "H:i";      // Style of time
$longdate = "d.m.Y H:i";   // Style of long time + date
$deftz = "Europe/London";
$pagename = "yrtest.php";

$geonameusr = "zzzzzz"; // IMPORTANT! You need to signup at geonames.org (FREE), put username here

// Cachesettings etc. settings
$qarefetchSeconds = 3600;   // How often it refresh the cache, 3600 recommended
$imgdir = "images/";   // Icons-folder
$jsfolder = "jquery/";
$cssfolder = "css/";
$cachefolder = "cache/";
$days = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');

// Default place
$cod = "GB";
$cou = "United Kingdom";
$cit = "Prescot";
$lat = 53.42948;
$lon = -2.80031;


I do have a valid geonames account, have activated it for free services and amended the url to http://api.geonames.org/searchJSON in the script.

I'm just using the yr.test page to get the script working properly before I try and integrate it into my own weatherpage template.

Thanks again for the suggestions.

Allan.

water01
Posts: 1460
Joined: Sat Aug 13, 2011 9:33 am
Weather Station: WH1081
Operating System: Windows 7 64bit HP SP1
Location: Somewhere in the USA
Contact:

Re: Dark Sky API

Postby water01 » Sat Jan 23, 2016 7:05 pm

I can only think that with the test page it defaults to the Timezone of your server whereas if you build a Forecast page and call yr_xmlII.php without the gubbins that does the look up in the yr-test.php the correct timezone will be set before it asks for the Forecast from yr_no.

AllanG
Posts: 5
Joined: Mon Oct 05, 2009 7:19 am
Weather Station: WeatherDuino Pro2
Operating System: Windows 10 Pro
Location: Prescot, Merseyside

Re: Dark Sky API

Postby AllanG » Sat Jan 23, 2016 8:14 pm

I thought / hoped I'd tried virtually everything I could find in code and you've more or less confirmed that for me. I'll try putting together my own page and see how it goes. Many thanks.

Allan.


Return to “Web site - General”

Who is online

Users browsing this forum: No registered users and 2 guests