NWS Weather Forecast Messenger PHP Script

If anybody is interested in using the new GeoTag API with twitter for your Forecast Tweets, modify the following function towards the bottom of the script:

function twitter_alert($twitter_message) {
 global $twitter_user, $twitter_password, $twitter_url, $user_agent, $latitude, $longitude;

  // Set up and execute the curl process
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
  curl_setopt($ch, CURLOPT_URL, "$twitter_url");
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, "status=$twitter_message&lat=$latitude&long=$longitude");
  curl_setopt($ch, CURLOPT_USERPWD, "$twitter_user:$twitter_password");
  $buffer = curl_exec($ch);
  curl_close($ch);

  echo '
';

  // check for success or failure for twitter message sending
  if (empty($buffer)) {
          echo 'WARNING: Twitter message not sent (check twitter settings)
';
  } else {
          echo 'A Twitter was sent:
';
          echo $twitter_message.'
';
          echo 'Twitter message length: '.strlen($twitter_message).'
';
  }

} // end function twitter_alert

The only changes were to the global variables and the CURLOPT_POSTFIELDS lines. MCHALLIS, thanks for a great script. I find it very useful.