function getSpaceWeather() {
    $url = "https://services.swpc.noaa.gov/json/solar_probabilities.json"; // The NOAA 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_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_VERBOSE, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    $response = curl_exec($ch); // Read the data from the NOAA Url into $response
 
    curl_close($ch);
    $data = json_decode($response); // Decode the response into an object
 
    $sr=(array) $data[0]; // Cast the JSON object into an array
 
    $html="C_class ".$sr["c_class_1_day"]; 
    $html.=" M_class ".$sr["m_class_1_day"];
    $html.=" X_class ".$sr["x_class_1_day"];
    $html.=" 10mev ".$sr["10mev_protons_1_day"];
    $html.=" 100mev ".$sr["100mev_protons_1_day"];
    $html.=" Polar ".$sr["polar_cap_absorption"];
 
    return $html; // return back the HTML
}

This API is really easy to use, and returns a 3 day window for C, M and X Class as well as 10mev and 100mev proton readings. The data is returned from the API and dumped into an Array() so you can easily change the output.

In its default config (above) it returns HTML, but can easily be changed to return the $sr array by removing the $html… lines and changing the return $html; to be return $sr;

echo getSpaceWeather();