diff --git a/lastestPostedDate.txt b/lastestPostedDate.txt index 80ef6c2..6483fbe 100644 --- a/lastestPostedDate.txt +++ b/lastestPostedDate.txt @@ -1 +1 @@ -Thu Mar 29 2012 10:53:23 GMT+0100 (BST) \ No newline at end of file +Tue Oct 14 2014 15:38:45 GMT+0530 (IST) \ No newline at end of file diff --git a/package.json b/package.json index 86869cc..1bd50ce 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "mime" : "1.2.x", "oauth" : "0.9.x", "qs" : "0.4.x", - "request" : "2.9.x" + "request" : "2.9.x", + "twit" : "" }, "devDependencies": {}, "optionalDependencies": {}, diff --git a/rss_app.js b/rss_app.js index a10d296..83aa5f7 100644 --- a/rss_app.js +++ b/rss_app.js @@ -1,27 +1,25 @@ var request = require('request'), - url = require('url'), - htmlparser = require('htmlparser'), - fs = require('fs'), - OAuth = require('oauth').OAuth; +url = require('url'), +htmlparser = require('htmlparser'), +fs = require('fs'), +Twit = require('twit'); // Config variables var rssUrl = 'http://feeds.bbci.co.uk/news/rss.xml'; var intervalLength = 2000; // Setup vars for twitter posting -var twitterConsumerKey = 'add your key here'; -var twitterConsumerSecret = 'add your secret here'; -var twitterAccessToken = 'add your token here'; -var twitterAccessTokenSecret = 'add your token secret here'; +var twitterConsumerKey = '...'; +var twitterConsumerSecret = '...'; +var twitterAccessToken = '...'; +var twitterAccessTokenSecret = '...'; -oAuth= new OAuth("http://twitter.com/oauth/request_token", - "http://twitter.com/oauth/access_token", - twitterConsumerKey, - twitterConsumerSecret, - "1.0A", - null, - "HMAC-SHA1" -); +var twitter = new Twit({ + consumer_key: twitterConsumerKey + , consumer_secret: twitterConsumerSecret + , access_token: twitterAccessToken + , access_token_secret: twitterAccessTokenSecret +}); // Get date of latest posted article var lastestPostedItemDate = getLatestPostedItemDate(); @@ -60,15 +58,13 @@ function setLatestPostedItemDate(date){ function publishToTwitter(item){ var tweet = item.title + ' ' + item.link; console.log('publishing to twitter'); - oAuth.post('http://api.twitter.com/1/statuses/update.json', - twitterAccessToken, - twitterAccessTokenSecret, - {'status': tweet}, - function(error, data) { - if(error) console.log(require('util').inspect(error)) - //else console.log('succcess!' + data) - }); - // + + twitter.post('statuses/update', { status: tweet }, function(err, data, response) { + if (err) + console.log(err); + console.log(data); + }); + } // looping on the server (every second)