简体   繁体   English

使用PHP监视转发

[英]Monitor retweets with PHP

I have a website Foo.com that creates a tweet for the user @FooWebsite. 我有一个网站Foo.com,它为用户@FooWebsite创建了一条推文。 Users on the website can retweet it and users directly on Twitter too. 网站上的用户可以转发它,用户也可以直接在Twitter上转发。

I would like to monitor in real-time (< 10min) the retweets of all the tweets created by @FooWebsite. 我想实时(<10分钟)监视@FooWebsite创建的所有推文的转发。

For the moment, I think of using a cronjob that requests Twitter every minute to get info (number of retweets) about those tweets as I have their IDs. 目前,我想使用一个cronjob,它每分钟请求Twitter,因为我有他们的ID,所以会获取有关这些推文的信息(转发数)。 Is there no subscription/callbacks like on Facebook API ? 是否没有Facebook API上的订阅/回调?

I'm using PHP5.5 on Unix/Apache. 我在Unix / Apache上使用PHP5.5。

If you want to count Retweets as they happen in real time, the recommended way is to use the Streaming APIs. 如果您想实时统计转发的数量,建议的方法是使用Streaming API。

In particular, the statuses/filter endpoint and its follow parameter will contain Retweets of any Tweet created by the user. 特别是, statuses/filter端点及其follow参数将包含用户创建的任何Tweet的Retweets。

In order to distinguish these Retweets from the other Tweets streamed by the endpoint, you can rely on the presence of a retweeted_status nested object which will embed the original Tweet, allowing you to identify and focus exclusively on Retweets and count the ones you are interested in. 为了将这些Retweets与端点发送的其他Tweets区别开来,您可以依靠retweeted_status嵌套对象的存在,该对象将嵌入原始Tweet,从而使您能够识别和专注于Retweet并计算感兴趣的Retweet 。

Please also note a retweet_count attribute value is attached to that node and represents, roughly, the number of times that original Tweet has been retweeted as of some time near when you were streamed the Tweet. 另请注意,该节点上附加了一个retweet_count属性值,它大致表示原始Tweet在您流式传输Tweet之前的某个时间被转发过的次数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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