Skip to content

Instantly share code, notes, and snippets.

Created April 9, 2011 10:16
Show Gist options
  • Save anildigital/911289 to your computer and use it in GitHub Desktop.
Save anildigital/911289 to your computer and use it in GitHub Desktop.
Twitter streaming API example twitter-node and
<title>Codesnippit NodeJS Twitter Tracker Client</title>
(function() {
var script = document.createElement("script");
script.src = "";
script.onload = function() {
$.getScript("http://localhost:3000/", function() {
var socket = new io.Socket("localhost", {"port": 3000});
socket.on("message", function(json) {
data = JSON.parse(json);
$("<li></li>").text("@" + data.user.screen_name + " " + data.text).prependTo("ul");
var http = require('http');
var config = {
user: "",
password: "",
track: ["ipl"]},
sys = require('sys');
server = http.createServer(function(req, res) { // create the server
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('<h1>Codesnippit Twitter Tracker Server is <span style="color: #bada55">operational</span></h1>');
var socket = require('').listen(server),
twitter = new (require("twitter-node").TwitterNode)(config);
.addListener('error', function(error){ // Always check for errors or they popup client side
.addListener('tweet', function(tweet){ // A new tweet that matches the criteria has been located
.addListener('limit', function(limit){ // New limit has been sent from the API
sys.puts('LIMIT: ' + sys.inspect(limit));
.addListener('delete', function(del){ // A delete event occured
sys.puts('DELETE: ' + sys.inspect(del));
.addListener('end', function(resp){ // API disconnect
sys.puts('wave goodbye...' + resp.statusCode);
Copy link

Hi, I cam across this and it looks awesome. I tried to get it working and I came across this error :

TwitterNode parser error: Object #<Manager> has no method 'broadcast'

Any thoughts on what it could be?


Copy link

petermk commented Mar 24, 2012

It's socket.emit, not socket.broadcast

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment