-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtwit-node.js
More file actions
28 lines (27 loc) · 739 Bytes
/
twit-node.js
File metadata and controls
28 lines (27 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var http = require('http'),
util = require('util');
var options = {
host: 'api.twitter.com',
port: 80,
path: '/1/statuses/user_timeline/nino0057.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));
});