Sim*_*mon 13 api twitter twitter-oauth twitter-streaming-api
我目前正在使用Twitter API来检索某些用户发布的推文.为了这个问题,我们将以@justinbieber为例.
使用https://stream.twitter.com/1.1/statuses/filter.json资源时,设置跟随所需的用户ID(@justinbieber = 27260086),并允许它运行,而我只想要@ justinbieber的推文我最终收到了他数百万粉丝发给他的推文.显然这意味着我得到的信息比我想要的多,而且从我发现的内容来看,我有时最终错过了用户自己的推文!
我尝试更改https://dev.twitter.com/docs/streaming-apis/parameters上的每个参数都无济于事.
以下参数说明:
For each user specified, the stream will contain:
Tweets created by the user.
Tweets which are retweeted by the user.
Replies to any Tweet created by the user.
Retweets of any Tweet created by the user.
Manual replies, created without pressing a reply button (e.g. “@twitterapi I agree”).
Run Code Online (Sandbox Code Playgroud)
正如在文档中那样,我会假设没有办法只获取用户的推文而不必自己过滤结果(如前所述,这意味着我最终可能会错过用户自己的推文!)但是我很想知道是否有人知道解决方法.
在任何人建议使用诸如status/user_timeline之类的东西之前,我知道它能够做我想要的,但是它有两个缺点让我继续使用流API:
我想做什么?@justinbieber只是一个高开销的Twitter账户的一个例子.我想使用此代码来检索许多高开销帐户的推文,从而提高速度,并且能够查看每个用户的每条推文都是需求.
小智 5
使用json_decode后,您可以使用以下IF语句来确定它是什么类型的推文:
// if it is a retweet
if (isset($data['retweeted_status']))
{
//TODO
}
// if it is a reply
else if (isset($data['in_reply_to_status_id_str']))
{
//TODO
}
// if it is a mention
else if (isset($data['in_reply_to_user_id_str']))
{
//TODO
}
// if it is an original tweet
else
{
//TODO
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1832 次 |
| 最近记录: |