Replies: 2 comments
-
Nothing has changed in the API. This is probably a question better addressed to a forum on custom weather web sites, like WxForum (https://www.wxforum.net/). |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks. I will direct my attention there. Thank you for the quick response. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a site that displays our current local weather and I just noticed that it is no longer displaying the city/state or the weather and icons. Has anything changed as far as how we pull the api data in? I have not changed anything in my php code that worked for over a year and now it doesn't work. ANy assistance is greatly appreciated!
Below is my code:
`<?php
//header('Content-type: application/json');
$points = 'https://api.weather.gov/points/32.8773,-80.0464';
$gridpoints = 'https://api.weather.gov/gridpoints/CHS/81,80/forecast/hourly';
$UserAgent = "www.mysite.com ([email protected])";
// Set the weather location here:
$lat = 32.8773;
$lng = -80.0464;
// HTTP stream options:
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept: application/geo+json;version=1\r\n" .
"User-agent: $UserAgent\r\n"
)
);
$context = stream_context_create($opts);
//stream the /points/lat,lng:
$pointMetaUrl = "https://api.weather.gov/points/$lat,$lng";
$pointMetaFile = file_get_contents($pointMetaUrl, false, $context);
$pointMetaArray = json_decode($pointMetaFile, true);
$pointTempUrl = "https://api.weather.gov/gridpoints/CHS/81,80/forecast/hourly";
$pointTempFile = file_get_contents($pointTempUrl, false, $context);
$pointTempArray = json_decode($pointTempFile, true);
// <------ CURRENT CONDITIONS ------> //
// Display Location - North Charleston, SC
$city = $pointMetaArray['properties']['relativeLocation']['properties']['city'];
$state = $pointMetaArray['properties']['relativeLocation']['properties']['state'];
// Display Current Condition Temperature
$tmp = $pointTempArray['properties']['periods'][0]['temperature'];
// Display Current Condition Image
$img = $pointTempArray['properties']['periods'][0]['icon'];
?>`
Beta Was this translation helpful? Give feedback.
All reactions