user-stream

2019-10-11

user-stream是什么

什么是user-stream,Simple twitter user stream client. Only one dependency (oauth).

user-stream使用教程帮助文档

user-stream

NPM module

Simple Node.js Twitter (API 1.1) user stream client (https://dev.twitter.com/docs/streaming-apis/streams/user)

NPM

Install

npm install user-stream

Usage

var Stream = require('user-stream');
var stream = new Stream({
    consumer_key: '',
    consumer_secret: '',
    access_token_key: '',
    access_token_secret: ''
});

//create stream
stream.stream();

//listen stream data
stream.on('data', function(json) {
  console.log(json);
});

Events

  • data- stream data in JSON format
  • garbage- stream data who can't be parsed to JSON
  • close- stream close event (stream connection closed)
  • error- error event (request error, response error, response status code greater than 200)
  • connected- stream created
  • heartbeat- twitter emitted heartbeat

Methods

  • stream- create stream connection
  • destroy- destroy/close stream connection

link">Streaming API request parameters link

var params = {
    with: 'user'
}
//create stream
stream.stream(params);

Reserved parameters for lib

  • delimited
  • stall_warnings

上一篇:formidable-plus
下一篇:hot-cocoa
相关教程
关注微信

扫码加入 JavaScript 社区

相关文章

首次访问,需要验证
微信扫码,关注即可
(仅需验证一次)

欢迎加入 JavaScript 社区

号内回复关键字:

回到顶部