Open HenrikBoChristoffersen opened 1 year ago
hi Henrik, very interesting!!! where I have to put this code?
Hi @iurban23
I'm using the plugin code snippet to manage to code. this creates a hook into the function.php so you dont need to change the code there. I also recommend to use Advanced Cron Manager to check of the cron scheduled job is added and running
Hi Jason
Congratulation with taking over the source code for weather station it was long needed, that someone carried it on onwards. We have been using the weather station module for number of years now and have developed quite a page combining data from weather station with other data sources see more details on: https://www.gillelejesejlklub.dk/vejret/
I'm also sharing data from weather station to https://stations.windy.com/ using some code I have built.
You are free to use the source code below if you want to include the capability in weather station.
function ws_get_windy_token( $token = "") { $token = " Register your station on https://stations.windy.com/ to get key "; // <- Replace this with your own token return $token; }
//-----------------------> Post to windy.com <---------------------------------
function ws_dopost($url, $json) { $fields = (is_array($json)) ? http_build_query($json) : $json;
if($ch = curl_init($url)) { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); $json = curl_exec($ch);
} else { return false; } }
//-----------------------> Get the weatherlink data for you upload <---------------------------------
function ws_get_weatherlinkdata($message = "" ) {
}
//-----------------------> main code code for sending data to windy <---------------------------------
function ws_put_weatherdata_to_windy( ) {
}
//-----------------------> adding the cron task for schedule job <--------------------------------- //-----------------------> remember to set the scedule to max 5 minutes <---------------------------------
add_action( 'init', function () {
} );
add_action( 'run_windy_update', function () {
} );