Giter Club home page Giter Club logo

ifttt's Introduction

IFTTT v1.0.0

IFTTT (If This Then That) is a service that allows you to easily connect triggers to actions across a plethora of products and services. This class allows an Electric Imp agent to trigger events on the IFTTT Maker Channel.

Class Usage

The IFTTT class provides three methods to send events to your IFTTT Maker Channel: with an eventName and no data, with an eventName and a single peice of data, and with an eventName and an array containing up to three peices of data.

Constructor: IFTTT(secretKey)

Creates an object that can be used to trigger events.

To get a secret key, sign into your IFTTT account and then click "Connect" on the Maker Channel page. You will then be directed to a page that contains your secret key. Copy just this key as a string into the constructor.

#require "IFTTT.class.nut:1.0.0"

// Replace this string with your secret key
ifttt <- IFTTT("<-- SECRET_KEY -->");

Class methods

sendEvent(eventName, [callback])

Triggers an IFTTT event with no argument values.

For details on callback construction, see sendEvent(eventName, valueArray, [callback])).

// Trigger an event with no values and a callback
ifttt.sendEvent("something_happened", function(err, response) {
    if(err) {
        server.error(err);
        return;
    }
    server.log("Success!!");
});

sendEvent(eventName, value1, [callback])

Triggers an IFTTT event with one argument value.

*For more details on the use of values and callback construction, see sendEvent(eventName, valueArray, [callback])).

// Trigger an event with one value and a callback
ifttt.sendEvent("something_happened", "red", function(err, response) {
    if(err) {
        server.error(err);
        return;
    }

    server.log("Success!");
});

sendEvent(eventName, valueArray, [callback])

Triggers an IFTTT event with up to 3 argument values.

All events must have a name that is linked to a specific IFTTT recipe.

Events may also have up to 3 optional parameter values, named value1, value2, and value3 that are passed through to the IFTTT recipe. These values can be placed in the valueArray parameter in the order that they should be received. To not use a particular value slot, leave it out of the array or set it to null (see example below). This method will throw an IFTTT.ERR_TOO_MANY_VALUES exception if more than 3 elements are placed in the valueArray array.

This method also optionally takes a callback that takes an err and a response. The response will always be the response object returned by httprequest.sendasync() and err will be non-null on HTTP errors.

// Trigger an event with 3 parameters and a callback
// value1: red
// value2: **don't send**
// value3: banana
ifttt.sendEvent("something_happened", ["red", null, "banana"], function(err, response) {
    if(err) {
        server.error(err);
        return;
    }

    server.log("Success!");
});

License

The IFTTT class is licensed under the MIT License.

ifttt's People

Contributors

cat-haines avatar doronshapiro avatar kaveman909 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.