Trying to add Tide data to my WF (from www.worldtides.info).
Is there some good manuals, how to make it?
I've tried to act as described in API manual, but it's complaining that "Permission Required", however, I opened permission for "Background" and "Communication" in manifest.
Developer's guide sad nothing about WF possibility for Communication, only for widgets and App, but, as I so, developers add somehow weather forecasts from internet into WF.
Means that I’m again doing something wrong.
here part of code, just to clear the idea:
function onReceieve(responseCode, data) {
if (responseCode == 200) {
System.println("Request Successful"); // print success
}
else {
System.println("Response: " + responseCode); // print response code
}
}
function makeRequest() {
var url = "www.worldtides.info/api // set the url
var params = { // set the parameters
"extremes" => "extremes",
"lat" => "47,095140",
"lon" => "37,541310",
"key" => "47cde680-420a-41eb-b278-c37ddcaxxxxx"
};
var options = { // set the options
:method => Communications.HTTP_REQUEST_METHOD_GET, // set HTTP method
:headers => { // set headers
"Content-Type" => Communications.REQUEST_CONTENT_TYPE_URL_ENCODED},
// set response type
:responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON
};
var responseCallback = method(:onReceive); // set responseCallback to
// onReceive() method
// Make the Communications.makeWebRequest() call
Communications.makeWebRequest(url, params, options, method(:onReceive));
}