Created
October 22, 2012 06:09
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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