Page 1 of 1

Dark Sky API

Posted: Sun 17 Jan 2016 10:59 pm
by bigmac
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

Re: Dark Sky API

Posted: Sun 17 Jan 2016 11:33 pm
by water01
This Forecast page from Yr,no is free http://www.dmjsystems.co.uk/weather/forecast.php

Re: Dark Sky API

Posted: Mon 18 Jan 2016 9:47 am
by mcrossley
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.

Re: Dark Sky API

Posted: Mon 18 Jan 2016 9:53 pm
by bigmac
Ok, thanks gents. Food for thought, I will probably be back with more questions at a later date!

Re: Dark Sky API

Posted: Sat 23 Jan 2016 4:43 pm
by AllanG
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.

Re: Dark Sky API

Posted: Sat 23 Jan 2016 5:29 pm
by water01
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.

Re: Dark Sky API

Posted: Sat 23 Jan 2016 5:36 pm
by water01
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

Re: Dark Sky API

Posted: Sat 23 Jan 2016 6:39 pm
by AllanG
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.

Re: Dark Sky API

Posted: Sat 23 Jan 2016 7:05 pm
by water01
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.

Re: Dark Sky API

Posted: Sat 23 Jan 2016 8:14 pm
by AllanG
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.