Skip to content

Instantly share code, notes, and snippets.

@jshaw
Created November 20, 2015 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jshaw/c7dd59af44f49d0ed024 to your computer and use it in GitHub Desktop.
Save jshaw/c7dd59af44f49d0ed024 to your computer and use it in GitHub Desktop.
particle iceland bike example
// http://apis.is/cyclecounter
// particle webhook GET ice_bikes "http://apis.is/cyclecounter"
// Jordans-MacBook-Pro:~ jshaw$ particle webhook GET ice_bikes "http://apis.is/cyclecounter"
// Sending webhook request { uri: 'https://api.particle.io/v1/webhooks',
// method: 'POST',
// json:
// { event: 'ice_bikes',
// url: 'http://apis.is/cyclecounter',
// deviceid: undefined,
// requestType: 'GET',
// mydevices: true },
// headers: { Authorization: 'Bearer f6f2c1d0ba4f1252b6eb4906d6cfebdf1e46b98b' } }
// Successfully created webhook with ID 564f648b74ddc084119db2a3
// attach an LED to D0
bool ice = true;
void setup() {
Serial.begin(115200);
Particle.subscribe("hook-response/ice_bikes", webhook_data, MY_DEVICES);
}
void loop() {
if(ice){
Particle.publish("ice_bikes");
ice = false;
}
delay(1000);
}
void webhook_data(const char *name, const char *data) {
String bikes = String(data);
Serial.println(bikes);
// bikes.indexOf(":");
// bikes = bikes.substring(bikes.indexOf(":"));
Serial.println(bikes.substring(25, 28));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment