More code examples?

It isn’t clear to me if I can, say, get the text of a tweet via IFTTT to be sent as a string to my Core.
Could someone post another example of how to use the text fields in IFTTT itself? When I make a Twitter recipe I end up with {{text}} in the function input or publish event/publish data fields. Very noob questions, but what do these do, what’s the difference between publish event and function inputs, what other things can one put in them, should one leave them as they end up by default, etc. I have an inkling of how it all works, but would be nice to get it confirmed.

Heya @spongefile,

When you use another channel as the trigger, the ‘ingredients’ from that trigger are available to you for use when hitting actions on the Spark Channel. Click the little blue “beaker” icon to the right of the text box, and select the ingredient you want to use. If you included the tweet text {{text}} or whatever the name is in the function input, then you’d get it say:

int your_function(String command) {
  Serial.println("The tweet was " + command);
}

If you sent it to yourself as event contents, you’d get it:

void your_handler(const char *topic, const char *data) {
  Serial.println("Your tweet was " + String(data));
}

Events can hit one or more of your subscribed devices, and a function call will only hit one of your devices. I hope that helps! More info here:

http://docs.spark.io/firmware/#spark-function

http://docs.spark.io/firmware/#spark-subscribe

Thanks,
David

2 Likes

Ahh missed that beaker icon, that helps a lot, thanks!