slsa1
// Set beach to use by defining beachkey
$endpoint = 'beach/nsw315A';
// Insert token you have been given.
$token = 'd4d686270269072c33536b3323cf784ee5478ddc305ab3e06accf7688d4c4deb';
// Create a new cURL resource handle
$ch = curl_init();
// Set URL to call (base url + endpoint)
curl_setopt($ch, CURLOPT_URL, 'https://beachsafe.org.au/api/v2/' . $endpoint);
// Set headers (including the token)
curl_setopt($ch, CURLOPT_HTTPHEADER, array('token: ' . $token));
// Should cURL return or print out the data? (true = return, false = print)
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Download the given URL, and store in $output variable
$output = curl_exec($ch);
// Close the cURL resource, and free system resources
curl_close($ch);
//echo $output."
";
$obj = json_decode($output);
$temp_now = $obj->{'weather'}->{'air_temp'};
$wind_speed = $obj->{'weather'}->{'wind_spd_kmh'};
$wind_dir = $obj->{'weather'}->{'wind_dir'};
echo "Temperature Now: ".round($temp_now)."°C
Wind: ".round($wind_speed)."kmh ".$wind_dir."";