Skip to content

Instantly share code, notes, and snippets.

@tcr
Created October 22, 2012 06:09
Show Gist options
  • Save tcr/3929939 to your computer and use it in GitHub Desktop.
Save tcr/3929939 to your computer and use it in GitHub Desktop.
Create a stream out of any REST endpoint with REM's polling utility.
// npm install rem
var rem = require('rem');
// Create Facebook API, prompting for key/secret.
var facebook = rem.load('facebook', 1).prompt();
// Authenticate user via the console.
rem.console(facebook, function (err, user) {
// Poll new statuses at an interval of 1 second, finding the array
// at the 'data' key and checking the 'date' key for date comparison.
rem.poll(user('me/statuses'), {
interval: 1000,
root: 'data',
date: 'updated_time'
}, function (err, json) {
console.log('# of new statuses:', json.length);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment