For instance I want the user to be able to select the closest Wunderground location, and then have the data accessible for that region. I can do this just fine by creating a custom webhook through the particle console, but what would be nice is for the user to be able to copy and paste the api address and the webhook automatically changed.
What is the best method for this?
Thanks
you can set the location city and state with a Particle.function()
then use that to Particle.publish() a call to a webhook that uses that information:
char requestString[64] = "";
snprintf(requestString, sizeof(requestString), "{\"my-city\":\"%s\",\"my-state\":\"%s\"}", userSpecificData.city, userSpecificData.stateAbbr);
Particle.publish("Current_Weather", requestString, PRIVATE);
set up your url in your integration to use the arguments:
http://api.wunderground.com/api/yourAPInumber/conditions/q/{{my-state}}/{{my-city}}.json
and create your own response template, like this:
{{#response}}{{#current_observation}}{{#estimated}}{{weather}}~{{temp_f}}~{{relative_humidity}}~{{wind_dir}}~{{wind_gust_mph}}~{{dewpoint_f}}~{{/estimated}}{{/current_observation}}{{/response}}
5 Likes
Thats very helpful, thanks I will try it out!