简体   繁体   中英

Node.js get live tweets from user

I am doing electron application using react.js. I want to get live tweets from a user. But it seems I can't find a right way to do it.

I am using Twit library for node.js

So far I have done this :

import React, {Component} from 'react'
import Twit from 'twit'

class aaa extends Component {
  constructor() {
    super()
  }

  componentDidMount() {
    const T = new Twit({
      consumer_key:         '...',
      consumer_secret:      '...',
      access_token:         '...-...',
      access_token_secret:  '...',
      timeout_ms:           60*1000,  // optional HTTP request timeout to apply to all requests.
    })
    let stream = T.stream('statuses/filter', { follow: '!username!' })

    stream.on('tweet', function (tweet) {
      console.log(tweet)
    })
  }

  render() {
    return(
      <div>
    </div>
    )
  }
}

export default aaa

This " follow: '!username!' " seems is not really a right way to do it. If I put here " track: 'word'" program works just fine. Any idea for solution?

Well I want to close this one. So I did as @Ratan Kumer suggest, found twitter ID on http://gettwitterid.com/ put follow: 'id' here and works like a charm.

Thank you!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM