<br /> <b>Warning</b>: file_get_contents(https://api.bloomsky.com/api/skydata): failed to open stream: HTTP request failed! HTTP/1.0 401 Unauthorized in <b>/home/content/96/5379896/html/bloomsky/bloomSkyLatest.php</b> on line <b>22</b><br /> <br /> <b>Warning</b>: file_get_contents(): Filename cannot be empty in <b>/home/content/96/5379896/html/bloomsky/bloomSkyLatest.php</b> on line <b>28</b><br />
<img src="http://bbbrown.com/pages/bloomSkyLatest.php"></img>
in my web page. I put my API in the script in the appropriate place I think, Could this be a conflict with Wordpress?
I'm getting an error message too. My link is http://bbbrown.com/pages/bloomSkyLatest.php . I usedThere is an " missing after the link in your example codeCode: [Select]<img src="http://bbbrown.com/pages/bloomSkyLatest.php></img>
in my web page. I put my API in the script in the appropriate place I think, Could this be a conflict with Wordpress?
<img src="http://bbbrown.com/pages/bloomSkyLatest.php"></img>
Check if that is there, it should be.I'm getting an error message too. My link is http://bbbrown.com/pages/bloomSkyLatest.php . I usedCode: [Select]<img src="http://bbbrown.com/pages/bloomSkyLatest.php></img>
in my web page. I put my API in the script in the appropriate place I think, Could this be a conflict with Wordpress?
header('Content-type: image/png');
$APIkey = "";
$url = "https://api.bloomsky.com/api/skydata";
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Authorization: ".$APIkey."\r\n"
)
);
$context = stream_context_create($opts);
$file = curl_get_contents($url, false, $context);
$data = json_decode($file, true);
$imageURL = $data[0]['Data']['ImageURL'];
echo curl_get_contents( $imageURL );
function curl_get_contents($url){
$ch = curl_init();
//curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; rv:19.0) Gecko/20100101 Firefox/19.0");
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
<?php ini_set('display_errors', 'On'); error_reporting(E_ALL);
?>
<img src="./bloomSkyLatest.php">
Thanks Wim,When these scripts are called in the browser,
in Paul's case though I dont understand the problem because it works when I try his link, I dont understand how can he get a different output from the server when he loads it in his browser... in Bob's case it obviously is due to the server configuration, but how can Paul's link work in my browser and not his. ](*,)
Okay. I placed it at http://bbbrown.com/weather/bloomsky-php-script-test/ (http://bbbrown.com/weather/bloomsky-php-script-test/) . The page loads with no error but there is a ghost image icon instead of the real thing.What did you place where.
Oh. sorry I didn't know that. I'll move it and try again.Okay. I placed it at http://bbbrown.com/weather/bloomsky-php-script-test/ (http://bbbrown.com/weather/bloomsky-php-script-test/) . The page loads with no error but there is a ghost image icon instead of the real thing.What did you place where.
The test-img.php script should be in the same folder as the bloomSkyLatest.php script.
Just to see the errors when executing.
Wim
Just to recap. I edited the original BloomskyLatest.php and added my API. It didn't work. I sent you my API key and it worked using your server.No sir, it is the strange behavior of some webservers and some assisting programs when uploading.
You sent the minimal test-image.php script which I placed in the same folder as the above script. When I point my browser to that I only get the text of the script returned. Probably because I don't know what I am doing.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1404.34">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #454545}
</style>
</head>
<body>
<p class="p1"><?php ini_set('display_errors', 'On'); error_reporting(E_ALL);</p>
<p class="p1">?></p>
<p class="p1"><img src="./bloomSkyLatest.php"></p>
</body>
</html>
So probably you are uploading this using a WYSIWG editor Cocoa HTML Writer.<?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($url, false, $context);
$data = json_decode($file, true);
$imageURL = $data[0]['Data']['ImageURL'];
echo file_get_contents( $imageURL );
?>
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
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 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.
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.
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
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 (http://weather.athelstanewi.com/wxbloom.php). Now I can add it along with my other webcam images. Cool stuff!
header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
'The image contains errors'
To understand what's going wrong you need to look in the error log
Alternatively you may temporarily comment out these 3 lines that should be near the end of the bloomSkyLatest.php script ( doing this the errors should be printed in the browser )Code: [Select]header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
hate to bring up an old topic but http://gosportwx.com/bloomSkyLatest.php doesn't work for me.. it use to with godaddy but not with fatcow host. Latest PHP version of new server is 7.3, and that isn't the issue.
br />
<b>Warning</b>: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in <b>/hermes/walnacweb03/walnacweb03aa/b1007/moo.cyrptoworldnet/Gosportwx/bloomSkyLatest.php</b> on line <b>22</b><br />
<br />
<b>Warning</b>: file_get_contents(https://api.bloomsky.com/api/skydata): failed to open stream: no suitable wrapper could be found in <b>/hermes/walnacweb03/walnacweb03aa/b1007/moo.cyrptoworldnet/Gosportwx/bloomSkyLatest.php</b> on line <b>22</b><br />