Author Topic: PHP script - Get the latest BloomSky image  (Read 5040 times)

0 Members and 1 Guest are viewing this topic.

Offline Bob3rd

  • Member
  • *
  • Posts: 31
Re: PHP script - Get the latest BloomSky image
« Reply #25 on: March 05, 2016, 11:50:48 AM »
Oh.  I am so sorry.  I'll have to find a plain text editor for my Mac.  My apologies.

Offline Bob3rd

  • Member
  • *
  • Posts: 31
Re: PHP script - Get the latest BloomSky image
« Reply #26 on: March 05, 2016, 12:38:53 PM »
It does appear that the .htaccess file in my public_html folder is configured for a local Wordpress instance which I use for my web site.  I will contact my hosting service to find a work around so I can run PHP files.  Thanks for your patience and help.

Offline sacreyweather

  • Echo Valley Weather
  • Forecaster
  • *****
  • Posts: 1543
    • Echo Valley Weather
Re: PHP script - Get the latest BloomSky image
« Reply #27 on: March 05, 2016, 01:15:59 PM »
Hi Jachym,

Works just fine here.

Thanks for taking the time to create this.

John
CWOP: D2073, GR2AE, GR3, Cumulus, PWSweather,  CoCoRaHS: AR-SL-23  

Saline Weather on Twitter
Blitzortung Station 1387

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8501
    • Meteotemplate
Re: PHP script - Get the latest BloomSky image
« Reply #28 on: March 05, 2016, 01:53:52 PM »
Great :-) At least for someone it works :D

OT: John is your website down? It throws a server error when I click the link in your profile

Offline sacreyweather

  • Echo Valley Weather
  • Forecaster
  • *****
  • Posts: 1543
    • Echo Valley Weather
Re: PHP script - Get the latest BloomSky image
« Reply #29 on: March 05, 2016, 02:12:34 PM »
Website isn't down. I may need to change the URL. Started using Cloudflare yesterday. Hang on a sec.

Please try again. Working for me.
CWOP: D2073, GR2AE, GR3, Cumulus, PWSweather,  CoCoRaHS: AR-SL-23  

Saline Weather on Twitter
Blitzortung Station 1387

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8501
    • Meteotemplate
Re: PHP script - Get the latest BloomSky image
« Reply #30 on: March 05, 2016, 05:10:58 PM »
 \:D/

Offline Bob3rd

  • Member
  • *
  • Posts: 31
Re: PHP script - Get the latest BloomSky image
« Reply #31 on: March 07, 2016, 02:38:51 PM »
Hi Jachym,

Did a little follow up and found that if I place a simple hello script in my public_html folder and call it with http://www.bbbrown.com/Bloomsky/hello.php I get a 404 error.  If I call it with http://bbbrown.com/Bloomsky/hello.php I get the proper response.  Having done that I then called the latest image using your script with http://bbbrown.com/Bloomsky/bloomSkyLatest.php I get a "unable to display the image "http://bbbrown.com/Bloomsky/bloomSkyLatest.php" cannot be displayed because it contains errors.  I think this is progress.  What do you think?

Also, you can see the PHP configuration of my server at http://bbbrown.com/phpinfo.php
« Last Edit: March 08, 2016, 10:18:57 AM by Bob3rd »

Offline chrisgrainger

  • Senior Member
  • **
  • Posts: 96
    • Top of The Rideau
Re: PHP script - Get the latest BloomSky image
« Reply #32 on: March 07, 2016, 04:03:31 PM »
Hi Jachym,

Thanks very much for the BloomSky latest image script.  Working fine here.  http://www.rideauwx.info/wxLatestBloomsky.php

Cheers!

Chris

Offline Bob3rd

  • Member
  • *
  • Posts: 31
Re: PHP script - Get the latest BloomSky image
« Reply #33 on: March 14, 2016, 03:23:04 PM »
I have not resolved my issue but I have been able to run the script that retrieves the latest image enough to get an error about the image. The URL http://bbbrown.com/Bloomsky/bloomSkyLatest.php returns an error image.

The error above continues with ....because it contains errors.
So, the script seems to be running correctly. I have checked my API key for the weather station and it is correct. Other people are able to run the script using their key and they are successful.  Any ideas?
Here's the code:
Code: [Select]
<?php

// get the latest BloomSky Image file
// fill in your API key and point your image src to this file

// Jachym, meteotemplate.com


header('Content-type: image/png');

ini_set("include_path"'/home/bbbrow5/php:' ini_get("include_path")  );


$APIkey "seCtg8zXqubZrNtntrHF2c0="// your API key

$url "https://api.bloomsky.com/api/skydata";

$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Authorization: ".$APIkey."\r\n"
)
);
$context stream_context_create($opts);
$file file_get_contents($urlfalse$context);

$data json_decode($filetrue);

$imageURL $data[0]['Data']['ImageURL'];

echo file_get_contents(  $imageURL );

?>
« Last Edit: March 14, 2016, 03:28:30 PM by Bob3rd »

Offline VaJim

  • Virginia Beach Backyard Weather
  • Forecaster
  • *****
  • Posts: 647
    • Virginia Beach Backyard Weather
Re: PHP script - Get the latest BloomSky image
« Reply #34 on: March 14, 2016, 07:04:34 PM »
Hi guys,
I have seen several people already asking about how to get the latest BloomSky image. Since it is a dynamic URL it is not as easy, so I created a little script which will do it for you.

Instructions:
1. Download the attached PHP file
2. Open the file in a text editor and insert your API key - if you don't have one, you need to get one for free from the official BloomSky developer's site
3. Upload the file anywhere on your server
4. For the image source on your page, use this php file.

eg:
<img src="...../bloomSkyLatest.php">

It should work, but since I cannot test properly because I dont have the camera, I would appreciate if someone could confirm it.

Enjoy


Nice work!

I only wish you were around back in the day when I pushed my data to my weather page.

Thanks for helping.

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8501
    • Meteotemplate
Re: PHP script - Get the latest BloomSky image
« Reply #35 on: March 14, 2016, 07:10:06 PM »
Hi guys,
I have seen several people already asking about how to get the latest BloomSky image. Since it is a dynamic URL it is not as easy, so I created a little script which will do it for you.

Instructions:
1. Download the attached PHP file
2. Open the file in a text editor and insert your API key - if you don't have one, you need to get one for free from the official BloomSky developer's site
3. Upload the file anywhere on your server
4. For the image source on your page, use this php file.

eg:
<img src="...../bloomSkyLatest.php">

It should work, but since I cannot test properly because I dont have the camera, I would appreciate if someone could confirm it.

Enjoy


Nice work!

I only wish you were around back in the day when I pushed my data to my weather page.

Thanks for helping.

Thanks :)


Bob3rd:
The only other thing I can think of is that there is some kind of firewall installed on your server which restricts the script from connecting to the BloomSky Api

Offline Bob3rd

  • Member
  • *
  • Posts: 31
Re: PHP script - Get the latest BloomSky image
« Reply #36 on: March 14, 2016, 07:23:59 PM »
I'm trying to discover the problem with my provider.  If we figure it out I will post here.  It has to do with the image.  The script runs.  So, there must be some restriction on retrieving the image.

Offline Bob3rd

  • Member
  • *
  • Posts: 31
Re: PHP script - Get the latest BloomSky image
« Reply #37 on: March 14, 2016, 08:28:44 PM »
Problem solved.  Turned out to be the version of PHP running on my server.  I changed from 5.3 to 5.5 and everything works now. 

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8501
    • Meteotemplate
Re: PHP script - Get the latest BloomSky image
« Reply #38 on: March 14, 2016, 08:50:16 PM »
 \:D/

Offline thewxobserver

  • Chester, Virginia
  • Member
  • *
  • Posts: 47
  • "Covering the weather one story at a time"
    • The Weather Lodge
Re: PHP script - Get the latest BloomSky image
« Reply #39 on: March 19, 2016, 02:41:55 PM »
Thanks for the script it has solved a problem of pulling the latest image for the website I am working on. Just a quick question is there a way to pull the image with the weather data from bloomsky on top?


Acurite Station / CWOP D0015 / WU KVACHEST36
Twitter @thewxobserver
RVA Weather Network

Offline StatenIslandWeather

  • Weather Hobbyist
  • Forecaster
  • *****
  • Posts: 528
  • Staten Island, New York
    • StatenIslandWeather
Re: PHP script - Get the latest BloomSky image
« Reply #40 on: March 22, 2016, 10:01:05 PM »
Thanks for the script it has solved a problem of pulling the latest image for the website I am working on. Just a quick question is there a way to pull the image with the weather data from bloomsky on top?
The data that is over-layed on the image is pulled from the Api. 
There is a simple website template posted here showing how it's done.
http://www.wxforum.net/index.php?topic=28635.0
Saratoga http://statenislandweather.net
Leuven http://dhweather.net
Meteotemplate http://donganhillsweather.net
HomeWeatherStation http://nyweather.net
HomeBrew http://w.nyweather.net

Ambient 1001 | ObserverIP | Meteobridge | MeteoPlug

Offline StatenIslandWeather

  • Weather Hobbyist
  • Forecaster
  • *****
  • Posts: 528
  • Staten Island, New York
    • StatenIslandWeather
Re: PHP script - Get the latest BloomSky image
« Reply #41 on: March 22, 2016, 10:02:26 PM »
Thanks for the script it has solved a problem of pulling the latest image for the website I am working on. Just a quick question is there a way to pull the image with the weather data from bloomsky on top?
The data that is over-layed on the image is pulled from the Api. 
There is a simple website template posted here showing how it's done.
http://www.wxforum.net/index.php?topic=28635.0
Saratoga http://statenislandweather.net
Leuven http://dhweather.net
Meteotemplate http://donganhillsweather.net
HomeWeatherStation http://nyweather.net
HomeBrew http://w.nyweather.net

Ambient 1001 | ObserverIP | Meteobridge | MeteoPlug

Offline kirklabs

  • Member
  • *
  • Posts: 3
Re: PHP script - Get the latest BloomSky image
« Reply #42 on: March 30, 2016, 11:10:22 PM »
Hey there Jachym (or anyone else who sees this) - noob question here...

Thanks for providing this!! I got the script installed and a link to the php image works fine (as in http://www.kirklabs.com/weather/smartphone/icons/bloomSkyLatest.php )

WeatherUnderground wants me to either ftp an image file or link to the URL of an image file for purposes of displaying a webcam image. It will not accept a link to a php file. I am not a developer so I might be missing something, but in the example above, how would I get a link to the actual .png image file?

JD

Offline hankster

  • Forecaster
  • *****
  • Posts: 447
    • NFM Weather
Re: PHP script - Get the latest BloomSky image
« Reply #43 on: March 30, 2016, 11:29:22 PM »
Use FTP, the Bloomsky is already setup to do that.


Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8501
    • Meteotemplate
Re: PHP script - Get the latest BloomSky image
« Reply #45 on: March 31, 2016, 05:00:55 AM »
Use the method suggested above. As far as I know there is no other way. The way this works is that in PHP you can set the headers, which define what sort of file type it will look like to the browser. So in the above script, you set the headers to JPG or PNG and the browser then things it is an image even though it is in fact a PHP script, which creates the image. The problem is however, that if you give it the png extension it will automatically be treated as an image, the server will not try to execute it and run the code, it will simply use the actual code as image data, which wouldn´t work.

Offline StatenIslandWeather

  • Weather Hobbyist
  • Forecaster
  • *****
  • Posts: 528
  • Staten Island, New York
    • StatenIslandWeather
Re: PHP script - Get the latest BloomSky image
« Reply #46 on: March 31, 2016, 12:44:37 PM »
Hey there Jachym (or anyone else who sees this) - noob question here...

Thanks for providing this!! I got the script installed and a link to the php image works fine (as in http://www.kirklabs.com/weather/smartphone/icons/bloomSkyLatest.php )

WeatherUnderground wants me to either ftp an image file or link to the URL of an image file for purposes of displaying a webcam image. It will not accept a link to a php file. I am not a developer so I might be missing something, but in the example above, how would I get a link to the actual .png image file?

JD

I'm almost positive I use the bloomSkyLatest.php as my image link and it works.
I'll have to double check.


Update: I checked WU and I am using the bloomSkyLatest.php file as my image and its working.
« Last Edit: April 03, 2016, 01:10:41 PM by StatenIslandWeather »
Saratoga http://statenislandweather.net
Leuven http://dhweather.net
Meteotemplate http://donganhillsweather.net
HomeWeatherStation http://nyweather.net
HomeBrew http://w.nyweather.net

Ambient 1001 | ObserverIP | Meteobridge | MeteoPlug

Offline mkutche

  • Forecaster
  • *****
  • Posts: 631
    • GosportWx.com
Re: PHP script - Get the latest BloomSky image
« Reply #47 on: October 17, 2016, 06:26:27 PM »
Hi Jachym,  Thanks for sharing the script!  I have been trying to figure a way to just get the current image using web cam software and this works great!  I put your script on my web server and then using Imagesalsa I call that script to get the latest image.  From there I can manipulate the image and then upload it up to may server.  Here is the result http://weather.athelstanewi.com/wxbloom.php.  Now I can add it along with my other webcam images.  Cool stuff!

How did you add N S E W and the current timestamp?? Looks awesome
Mike K.
WS2080 - Cumulus v.1.9.4
Gosport, Indiana
http://www.gosportwx.com   http://www.gosportwx.com/CU-X5   twitter.com/GosportINWX   facebook.com/GosportWxcom-112746546060840/  
-----------------------------------------------------------

Offline ke9lz

  • De Pere - Athelstane Weather
  • Contributor
  • ***
  • Posts: 124
    • De Pere Weather
Re: PHP script - Get the latest BloomSky image
« Reply #48 on: October 17, 2016, 07:13:12 PM »
Hi Mike,  I use Imagesalsa to download the picture, add the N S E W as well as the time stamp and then upload it to the server.  It's to bad Imagesalsa is outdated and hasn't kept up with the times but in it's day it was I think the best webcam software out there.  You can still download it and it's free now at http://www.imagesalsa.com/.
Steve (KE9LZ)
Athelstane Weather
Blitzortung 1177, 1565


Offline vnephologist

  • Member
  • *
  • Posts: 2
    • Weather Underground PWS
Re: PHP script - Get the latest BloomSky image
« Reply #49 on: May 03, 2017, 09:53:52 PM »
Jáchym, I'm thinking of hosting the script on my Meteobridge and then pointing the webcam image upload config url to localhost. I'm pretty sure the Meteobridge url parameter is expecting only an image to be returned, not html with an image. Planning to work on this soon. Any tips? Thanks!