Hi.

Node-twitter is a nodejs module. There are many great apps being released with realtime capabilities not usually found in d.o. project modules.

My use case is the node_twitter npm package.
To install node-twitter and its dependencies with npm: npm install twitter

Here is the code required to get drupal releated tweets into nodejs objects, just needs the keys and secret. If it could be pluggable for any generic node_module npm package, it would be great!


var http = require('http');
require('node-monkey').start({host: "127.0.0.1", port:"8000"}); // just a tool to visualise nodejs objects in the browser console. Optional

// Configure our HTTP server to respond with Hello World to all requests.
var server = http.createServer(function (request, response) {
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.end("Hello World\n");
});

// Listen on port 8000, IP defaults to 127.0.0.1
server.listen(8000);

// Put a friendly message on the terminal
console.log("Server running at http://127.0.0.1:8000/");

 process.stdin.resume();
  process.stdin.setEncoding('utf8');
  var util = require('util');

  process.stdin.on('data', function (text) {
    console.log('received data:', util.inspect(text));
    if (text === 'quit\n') {
      done();
    }
  });

var Twitter = require('twitter');

var client = new Twitter({
  consumer_key: '',
  consumer_secret: '',
  access_token_key: '',
  access_token_secret: ''
});

client.stream('statuses/filter', {track: 'drupal'}, function(stream) {
  stream.on('data', function(tweet) {
    console.log(tweet);
  });

  stream.on('error', function(error) {
    throw error;
  });
});

  function done() {
    console.log('Now that process.stdin is paused, there is nothing more to do.');
    process.exit();
  }

EDIT: Fixing broken link
I really not sure how to get this into twig, should I use perhaps twig.js?
-Thanks.

Comments

j_nunes created an issue. See original summary.

Yorgg’s picture

Issue summary: View changes