diff --git a/CHANGELOG.md b/CHANGELOG.md index ba7558a..581db69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ Change log ========== +1.4.0 +----- + +* 🎁 Add extra header `Authorization` for API calls, improve documentation for API keys + 1.3.1 ----- diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f4246d1..f152dba 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,8 +16,8 @@ This project was built with Microsoft Visual Studio 2017. Dependencies: -1. [Curl](https://curl.haxx.se/): Install via `vcpkg install curl curl:x64-windows`. -1. [WxWidgets](https://www.wxwidgets.org/): Install via `vcpkg install wxwidgets wxwidgets:x64-windows`. +1. [Curl](https://curl.haxx.se/): Install via `vcpkg install curl curl:x64-windows` +1. [WxWidgets](https://www.wxwidgets.org/): Install via `vcpkg install wxwidgets wxwidgets:x64-windows` Remember to integrate via `vcpkg integrate install`. diff --git a/README.md b/README.md index 1df2589..84bd74a 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,10 @@ Installation 1. Download the latest release ZIP from https://github.com/fboes/aerofly-wettergeraet/releases/latest. 2. Unpack the ZIP file to some sensible location, e.g. `C:\Program Files\aerofly-wettergeraet-x64\`. +3. You will also need an API key for the [AVWX REST API](http://avwx.rest/), which can be acquired at https://account.avwx.rest 3. Create a shortcut on your desktop by right-clicking `aerofly-wettergeraet-desktop.exe` > "Send to" > "Desktop (Create shortcut)". You might want to re-label the shortcut to "Aerofly Wettergerät". +3. Supply your API key, see [the configuration guide](docs/configuration.md) 3. Start the desktop application by clicking on the desktop link. In case you want to use this application on a different operation system, consider [building your own executable from this project](CONTRIBUTING.md). @@ -65,7 +67,7 @@ HTTP services This tool is compatible with the following METAR services: -* [AVWX](http://avwx.rest/): This is the default HTTP service. +* [AVWX](http://avwx.rest/): This is the default HTTP service. You will need to get an API key to use this service. * [CheckWX](https://www.checkwx.com/): You will need to get an API key to use this service. You may also try any other HTTP service which offers METAR information as raw text or JSON. See the [configuration guide on how to set different METAR services](docs/configuration.md). diff --git a/docs/configuration.md b/docs/configuration.md index 8e52cc5..f722515 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -5,40 +5,22 @@ For more information about command line options, call the command line variant o There is also a [source code documentation on command-line parameters](https://github.com/fboes/aerofly-wettergeraet/blob/master/src/WettergeraetLib/Argumentor.cpp#L65) applicable for the command-line as well as the desktop variant of this tool. -To append parameters to the desktop application, right-click your desktop icon, select "Properties" and append the parameter(s) to the shortcut's target. +Supplying parameters to the desktop application +----------------------------------------------- -![](modify-shortcut.png) - -Register file associations --------------------------- - -You may register `.mcf` and `.rwx` file types with the desktop version of the Aerofly Wettergerät by double-clicking these files. This will open up the application with the corresponding file loaded. - -HTTP services -------------- - -This tool has been tested with multiple METAR services. To change the METAR service for the command line variant `aerofly-wettergeraet.exe` append additional parameters: - -```batch -: Supply METAR manually -aerofly-wettergeraet.exe --metar ? - -: AVWX - this is the default HTTP service -aerofly-wettergeraet.exe --url "http://avwx.rest/api/metar/XXXX?options=&format=json&onfail=cache" +To supply parameters to the desktop application, right-click your desktop icon, select "Properties" and append the parameter(s) to the shortcut's target, like `--PARAMETER_NAME "PARAMETER_VALUE"`, e.g. `--apikey "ABCDEF"` to supply an API key. -: CheckWX - you will need to get an API key -aerofly-wettergeraet.exe --url "https://api.checkwx.com/metar/XXXX/decoded" --apikey "INSERT API KEY HERE" -``` +![](modify-shortcut.png) -To change the METAR service for the desktop variant `aerofly-wettergeraet-desktop.exe` change the target of your desktop shortcut: +These parameters are available: -```batch -: AVWX - this is the default HTTP service -aerofly-wettergeraet-desktop.exe --url "http://avwx.rest/api/metar/XXXX?options=&format=json&onfail=cache" - -: CheckWX - you will need to get an API key -aerofly-wettergeraet-desktop.exe --url "https://api.checkwx.com/metar/XXXX/decoded" --apikey "INSERT API KEY HERE" -``` +| Parameter | Example value | Description | +| ------------- | ----------------------- | ------------------------------------------ | +| `--file` | `C:\Users\...\main.mcf` | Absolute file location of your `main.mcf`. | +| `--url` | `http://avwx.rest/api/metar/XXXX?options=&format=json&onfail=cache` | Fetch response via HTTP from this URL. If URL contains `XXXX` this will be replaced by the ICAO airport code. | +| `--apikey` | `12345abcd` | Sent HTTP header `X-API-Key` / `Authorization` set to this value for all HTTP API calls. | +| `--response` | `raw` | How to interpret HTTP response. Set this to `raw` if the response is plain text. Set this to `json` if the response is JSON object. | +| `--hours` | `-8` | Offset time read from METAR code by this value, given in hours. | Change default values --------------------- @@ -51,7 +33,7 @@ These variables are available: | -------------------- | ----------------------- | ------------------------------------------ | | `AEROFLYWX_FILE` | `C:\Users\...\main.mcf` | Absolute file location of your `main.mcf`. | | `AEROFLYWX_URL` | `http://avwx.rest/api/metar/XXXX?options=&format=json&onfail=cache` | Fetch response via HTTP from this URL. If URL contains `XXXX` this will be replaced by the ICAO airport code. | -| `AEROFLYWX_APIKEY` | `12345abcd` | Sent HTTP header `X-API-Key` set to this value for all HTTP API calls. | +| `AEROFLYWX_APIKEY` | `12345abcd` | Sent HTTP header `X-API-Key` / `Authorization` set to this value for all HTTP API calls. | | `AEROFLYWX_RESPONSE` | `raw` | How to interpret HTTP response. Set this to `raw` if the response is plain text. Set this to `json` if the response is JSON object. | | `AEROFLYWX_HOURS` | `-8` | Offset time read from METAR code by this value, given in hours. | @@ -76,6 +58,11 @@ For Mac OSX / Linux open up a terminal and enter the following lines: VARIABLE="VALUE" ``` +Register file associations +-------------------------- + +You may register `.mcf` and `.rwx` file types with the desktop version of the Aerofly Wettergerät by double-clicking these files. This will open up the application with the corresponding file loaded. + --- Return to [table of contents](README.md). diff --git a/src/WettergeraetLib/Argumentor.cpp b/src/WettergeraetLib/Argumentor.cpp index c007287..dd4c3ec 100644 --- a/src/WettergeraetLib/Argumentor.cpp +++ b/src/WettergeraetLib/Argumentor.cpp @@ -3,7 +3,7 @@ #include #include -const char* Argumentor::APP_VERSION = "1.3.1"; +const char* Argumentor::APP_VERSION = "1.4.0"; #if _WIN64 const char* Argumentor::APP_TARGET = "64-bit"; #else diff --git a/src/WettergeraetLib/FetchUrl.cpp b/src/WettergeraetLib/FetchUrl.cpp index 5523003..4a43b08 100644 --- a/src/WettergeraetLib/FetchUrl.cpp +++ b/src/WettergeraetLib/FetchUrl.cpp @@ -58,6 +58,8 @@ std::string FetchUrl::fetch(std::string url, unsigned short fetchMode, std::stri if (apiKey != "") { apiKey = "X-API-Key: " + apiKey; httpHeaders = curl_slist_append(httpHeaders, apiKey.c_str()); + apiKey = "Authorization: " + apiKey; + httpHeaders = curl_slist_append(httpHeaders, apiKey.c_str()); } curl_easy_setopt(curl, CURLOPT_URL, url.c_str());