Home>
I wanted to get Tweet in real time with Node.js + Twitter streaming API. I used the twit module and executed the program as follows, but I couldn't import the data into Milkcocoa well.
What are the possible causes?
// Test using Twitter for Node.js
var Twit = require ('twit');
var MilkCocoa = require ('./ index.js');// Read SDK for Milkcocoa
var milkcocoa = new MilkCocoa ("*****. mlkcca.com");
var ds = milkcocoa.dataStore ("tweets");
// Please set the correct key below ----- (* 1)
var T = new Twit ({
consumer_key:'*******&apos ;,
consumer_secret:'*******&apos ;,
access_token:'*******&apos ;,
access_token_secret:'*******'
});
// Show tweets about JavaScript ---- (* 2)
var stream = T.stream ('statuses/filter&apos ;, {track:'keyword1, keyword2'});
// Set an event to be called when there is a tweet --- (* 3)
stream.on ('tweet&apos ;, function (tw) {
var text = tw.text;
var user_name = tw.user.name;
ds.push ({
'title':'user_name&apos ;,
'content':'text'
});
console.log (user_name +">"+ text);
});