Guest User

Untitled

a guest
Oct 12th, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. var https = require('https')
  2. , username = 'YOUR_TWITTER_USERNAME'
  3. , password = 'YOUR_TWITTER_PASSWORD'
  4. , keyword = 'chocolate'
  5. , json;
  6.  
  7. var options = {
  8. host: 'stream.twitter.com',
  9. auth: username + ':' + password,
  10. path: '/1/statuses/filter.json?track=' + keyword,
  11. method: 'POST'
  12. };
  13.  
  14. var req = https.request(options, function(res) {
  15. res.setEncoding('utf8');
  16. res.on('data', function (data) {
  17. json = JSON.parse(data);
  18. console.log('New data event!');
  19. console.log(json.text);
  20. });
  21. });
  22.  
  23. req.end();
Add Comment
Please, Sign In to add comment