Skip to content

Instantly share code, notes, and snippets.

@ncb000gt
Forked from gaurish/gist:888555
Created March 27, 2011 03:59
Show Gist options
  • Select an option

  • Save ncb000gt/888895 to your computer and use it in GitHub Desktop.

Select an option

Save ncb000gt/888895 to your computer and use it in GitHub Desktop.

Revisions

  1. ncb000gt revised this gist Mar 27, 2011. 1 changed file with 15 additions and 2 deletions.
    17 changes: 15 additions & 2 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,27 @@
    var http = require('http');
    var http = require('http'),
    util = require('util');
    var options = {
    host: 'api.twitter.com',
    port: 80,
    path: '/1/statuses/public_timeline.json'
    };

    var chunks = [],
    total = 0;

    http.get(options, function(res) {
    console.log('Got response ' + res.statusCode);

    }).on('data', function(chunk) {
    chunks.push(chunk);
    total+= chunk.length;
    }).on('error', function(e) {
    console.log('Got Error ' + e.message);
    }).on('end', function() {
    var buf = new Buffer(total)
    cur = 0;
    for (var i = 0, l = chunks.length; i < l; i++) {
    chunks[i].copy(buf, cur, 0);
    cur += chunks[i].length;
    }
    console.log(util.inspect(buf.toString(), true, 5));
    });
  2. @invalid-email-address Anonymous created this gist Mar 26, 2011.
    14 changes: 14 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    var http = require('http');
    var options = {
    host: 'api.twitter.com',
    port: 80,
    path: '/1/statuses/public_timeline.json'
    };


    http.get(options, function(res) {
    console.log('Got response ' + res.statusCode);

    }).on('error', function(e) {
    console.log('Got Error ' + e.message);
    });