[英]Node.js get live tweets from user
I am doing electron application using react.js. 我正在使用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 我正在将Twit库用于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.
如果我在这里输入“ track:'word'”程序就可以了。 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. 因此,我按照@Ratan Kumer的建议进行操作,在http://gettwitterid.com/上找到了Twitter ID,并在其上输入
follow: 'id'
,并像一种魅力一样工作。
Thank you! 谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.