Hi I am trying to access the twitter rest api https://stream.twitter.com/1.1/statuses/filter.json I am using nodejs.
For authentication I have used ntwitter. Authentication is going through fine. I get the success message.
But once it passes authentication it is not displaying tweets. it shows something like.
----------------------------------------
o/p
----------------------------------------------------------------
tweet[object Object]
success
tweet[object Object]
tweet[object Object]
tweet[object Object]
My prog
-------------------------------------
var twitter = require('ntwitter');
var https = require('https');
var twit = new twitter({
consumer_key: "xxxxxxxxxxxxx",
consumer_secret: "xxxxxxxxxxxxxxxxxxxxxxx",
access_token_key: "xxxxxxxxxxxxxxxxxxxxx",
access_token_secret: "xxxxxxxxxxxxxxxxxx"
});
twit.verifyCredentials(function (err, data) {
console.log("success");
});
twit.stream('statuses/filter', {track:'manipal'}, function(response) {
var body ='';
response.on("data",function(chunk){
//var tweet = JSON.parse(chunk);
console.log("tweet" + chunk);
});
response.on("end",function(){
console.log('Disconnected');
});
});
Looking at the ntwitter test suite, it seems the tweet object has the properties text and user. So if you do console.log("tweet: " + chunk.text), you might have more success.
By using string addition you are converting the tweet object into a string representation. Because it has no toString() method, it outputs to the console as [object Object].
Try either console.log(chunk); or console.log("tweet "+chunk.text);