What you’ll learn: How to create a circuit that posts an action to your profile on the Open Graph.
What you'll need:
- An Electric Imp
- An Electric Imp breakout board, or an Arduino + an Electric Imp Shield
- A switch or some wire
| /** A low-level look at an HTTP API */ | |
| // Make the GET request to the Facebook API. | |
| Facebook.get("me/notifications?limit=1", access_token); | |
| Facebook.match(onNotification, "data", JSON_ARRAY, "title"); // "data" key, find ARRAY, identify each "title" key | |
| Facebook.match(onError, "error"); | |
| Facebook.request(); | |
| // Make the GET request to the Facebook API. | |
| Facebook.post("me/feed", access_token); |
| /* | |
| * Modified from WiFlyHQ Example httpclient.ino | |
| * | |
| * This sketch implements a simple Web client that connects to a | |
| * web server, sends a GET, and then sends the result to the | |
| * Serial monitor. | |
| * | |
| * This sketch is released to the public domain. | |
| * | |
| */ |
| // npm install rem read | |
| var rem = require('rem') | |
| , fs = require('fs') | |
| , read = require('read'); | |
| var tw = rem.connect('twitter.com', '1.1') | |
| , oauth = rem.oauth(tw); | |
| // Add whichever API keys you want to test here. | |
| // Including the iPhone/Android apps, these keys are configured as "desktop" |
| var rem = require('rem'); | |
| var api = rem.createClient({ | |
| base: 'http://www.startuppack.org/v1/', | |
| uploadFormat: 'form' | |
| }); | |
| api('users').post({ | |
| token: ..., // your token | |
| email: "[email protected]", |
| // GraphButton source code | |
| // Set output port for planner. | |
| local output = OutputPort("trigger"); | |
| // Callback when the button is pressed. | |
| function pin7changed() { | |
| local buttonState = hardware.pin7.read(); | |
| // If buttonState is 0, the button is pushed. |
var isNode = typeof process != 'undefined' && process.versions && process.versions.node;
var isBrowser = typeof window != 'undefined';
var isModule = typeof module != 'undefined' && module.exports;
This converter converts between entities.
| // npm install rem read | |
| var rem = require('rem') | |
| , read = require('read'); | |
| var github = rem.connect('github.com', 3.0) | |
| read({ prompt: 'Username: '}, function (err, username) { | |
| github('users', username, 'repos').get(function (err, repos) { | |
| console.log(repos); | |
| }); |
| // Calls functions once a promise has been delivered. | |
| // var p = promise(); | |
| // Queue functions: p(yourCallback) | |
| // Deliver the promise: promise.deliver([args...]). | |
| // Once the promise has been delivered, p(yourCallback) immediately calls the callback. | |
| function promise () { | |
| var queue = [], args = null; | |
| var promise = function (fn) { | |
| if (promise.delivered) { |