了解twitter流式api响应

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了了解twitter流式api响应相关的知识,希望对你有一定的参考价值。

我不是一个非常狂热的用户,因此很难弄清楚每个字段在twitter api响应中的含义。通过文档只会导致我进入圈子。

我想要做的是分析事情是如何变成病毒的。所以,我所做的是从twitter流式api中获取数据,希望分析响应,但我完全感到困惑。所以json的一个示例响应是:

{"created_at":"Thu Mar 14 18:19:12 +0000 2013","id":312266679390457857,"id_str":"312266679390457857","text":"The first four winners of our March Madness Giveaway (4x ADATA Technology (USA) 16GB DashDrives) are:

Aaron... http://t.co/ikPbfRZQdq","source":"u003ca href="http://www.facebook.com/twitter" rel="nofollow"u003eFacebooku003c/au003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":179622147,"id_str":"179622147","name":"Levetron","screen_name":"Levetron","location":"Los Angeles","url":"http://www.aziocorp.com","description":"Official Twitter for Levetron by AZiO. Here for customer questions, gaming tips & tricks, sharing cool ideas, product launch releases, reviews and more!","protected":false,"followers_count":1042,"friends_count":25,"listed_count":4,"created_at":"Tue Aug 17 18:56:29 +0000 2010","favourites_count":5,"utc_offset":-28800,"time_zone":"Pacific Time (US & Canada)","geo_enabled":false,"verified":false,"statuses_count":707,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"131516","profile_background_image_url":"http://a0.twimg.com/images/themes/theme14/bg.gif","profile_background_image_url_https":"https://si0.twimg.com/images/themes/theme14/bg.gif","profile_background_tile":true,"profile_image_url":"http://a0.twimg.com/profile_images/3223061028/999ac6efc782d85983cbcf7f2deab7c1_normal.png","profile_image_url_https":"https://si0.twimg.com/profile_images/3223061028/999ac6efc782d85983cbcf7f2deab7c1_normal.png","profile_banner_url":"https://si0.twimg.com/profile_banners/179622147/1360294489","profile_link_color":"009999","profile_sidebar_border_color":"EEEEEE","profile_sidebar_fill_color":"EFEFEF","profile_text_color":"333333","profile_use_background_image":true,"default_profile":false,"default_profile_image":false,"following":null,"follow_request_sent":null,"notifications":null},"geo":null,"coordinates":null,"place":null,"contributors":null,"retweet_count":0,"entities":{"hashtags":[],"urls":[{"url":"http://t.co/ikPbfRZQdq","expanded_url":"http://fb.me/M6YPCk9W","display_url":"fb.me/M6YPCk9W","indices":[112,134]}],"user_mentions":[]},"favorited":false,"retweeted":false,"possibly_sensitive":false,"filter_level":"medium"}

1)我的猜测是,如果这条推文是转发的结果,那么“转推”应该是真的。但是,我如何弄清楚它转发给哪个用户? 2)“id”用户ID或推文ID?

基本上,如果我想说我想分析江南风格是如何传播病毒的......谁转发/关注那条特定的推文,我该怎么办呢?

此外,Twitter最近改变了它的api。我正在使用python,但在我看来,所有这些api的例子都不起作用

For example: https://github.com/tweepy/tweepy

有什么建议。谢谢

答案

请参阅有关推文的Twitter API documentation。它描述了Twitter JSON响应中返回的所有参数。

那条推文没有被转发,因为retweeted设置为false而retweeted_count为0。

从文档:

id =此推文的唯一标识符的整数表示形式。

转发可以通过retweeted_status属性的存在与典型的推文区分开来。此属性包含转发的原始推文的表示形式。

此外,here是受支持的推特库列表。列出的除了tweepy之外还有其他几个库可能对您有用。

以上是关于了解twitter流式api响应的主要内容,如果未能解决你的问题,请参考以下文章

ColdFusion 和流式 API...(即 Twitter)

使用 Python Tweepy 的 Twitter 流 API

使用 Twitter API 发送直接消息不起作用

流式传输 Twitter 直接消息

Twitter 搜索 API 响应?

Twitter使用Spark流式传输