1#include <boost/date_time/posix_time/conversion.hpp>
2#include <boost/date_time/posix_time/posix_time.hpp>
23size_t writeFunction(
void *ptr,
size_t size,
size_t nmemb, std::string *data) {
24 data->append((
char *)ptr, size * nmemb);
29 std::string metarInfo;
30 const std::string url =
31 "https://tgftp.nws.noaa.gov/data/observations/metar/stations/" + ICAO +
37 curl_global_init(CURL_GLOBAL_DEFAULT);
39 curl = curl_easy_init();
41 log_cmd(
"Unable to initalize CURL",
"CURL",
42 boost::posix_time::to_time_t(
43 boost::posix_time::second_clock::universal_time()),
48 curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
50 curl_easy_setopt(curl, CURLOPT_WRITEDATA, &metarInfo);
52 res = curl_easy_perform(curl);
54 log_cmd(curl_easy_strerror(res),
"CURL",
55 boost::posix_time::to_time_t(
56 boost::posix_time::second_clock::universal_time()),
59 curl_easy_cleanup(curl);
60 curl_global_cleanup();