Skip to content

Instantly share code, notes, and snippets.

@artcommacode
Created December 11, 2011 15:07
Show Gist options
  • Save artcommacode/1461021 to your computer and use it in GitHub Desktop.
Save artcommacode/1461021 to your computer and use it in GitHub Desktop.
var twitter = require('ntwitter')
, jsdom = require('jsdom')
, Log = require('log')
, fs = require('fs')
, log = new Log('info', fs.createWriteStream('app.log'))
, XXX;
var twit = new twitter({
consumer_key: 'XXX',
consumer_secret: 'XXX',
access_token_key: 'XXX',
access_token_secret: 'XXX'
});
sendTweet();
setInterval(function(){
sendTweet();
}, 5*60*1000);
function sendTweet() {
jsdom.env('XXX', [
'http://code.jquery.com/jquery-1.7.1.min.js'
],
function(errors, window) {
var $ = window.$;
var status = $.extend({}, XXX);
// possibly modify status
if (JSON.stringify(status) != JSON.stringify(XXX)) {
var message = XXX;
twit
.verifyCredentials(function (err, data) {
//console.log(console.dir(data));
})
.updateStatus(message,
function (err, data) {
log.info('Sent \'%s\' to twitter.', message);
//console.log(console.dir(data));
}
);
XXX = $.extend({}, status);
} else {
log.info('No status change.');
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment