-
-
Save ncb000gt/888895 to your computer and use it in GitHub Desktop.
Revisions
-
ncb000gt revised this gist
Mar 27, 2011 . 1 changed file with 15 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,27 @@ 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)); }); -
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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); });