Twitter streaming API

Source: Internet
Author: User
Tags oauth

There are real-time updates on Facebook, which can accept user updates in real time. There are three streaming APIs, namely streaming API, user streams, and site streams, which are more powerful than Twitter, this article mainly discusses the first two. The basic idea is to connect to Twitter streams and create a persistent connection. Do not close it. Then, Twitter will send updates to this connection in real time. What you need to do is to continuously accept updates from this connection, then process it. To use stream APIs, oauth verification is required. This is different from Facebook (you only need to add the token parameter to the request). Of course, there are many good libary options that you can use, such as hammock, tweetsharp, and twitterizer.

 

Streaming API

You can subscribe to updates from multiple users on Twitter. What about those users? There are many criteria for filtering. The streaming API has multiple methods:

1) statuses/Filter

Returns the user status update notification and filters users by parameters.

Parameters: Count, delimited, follow, locations, and track. For example, through "follow = 356,398", you can subscribe to status updates for users whose user IDs are 356 and 398.

2) statuses/firehose

3) statuses/Links

4) statuses/retweet

5) statuses/sample

This is an example. Some updates are randomly returned by the system for your test. This interface does not require oauth verification and can be verified using basic.

The returned content is JSON and includes the status update content, as follows:

 

{ " Text " : " Pls tell me " , " In_reply_to_status_id " : Null , " Truncated " : False , " Source " : " \ U003ca href = \ "http: \ // seesmic.com \/seesmic_desktop \/SD2 \" rel = \ "nofollow \" \ u003eseesmic Desktop \ u003c \/A \ u003e " , " In_reply_to_user_id " : Null , " Favorited " : False , " Entities " :{ " URLs " : [], " User_mentions " : [], " Hashtags " : []}, " In_reply_to_screen_name " : Null , " In_reply_to_status_id_str " : Null , " Id_str " : " 52910061479133184 " , " Place " : Null , " Created_at " : " Wed Mar 30 01:48:36 + 0000 2011 " , " Contributors " : Null , " User " :{ " Show_all_inline_media " : False , " Follow_request_sent " : Null , " Geo_enabled " : True , " Communications " : Null , " Profile_sidebar_border_color " : " C0deed " , " Contributors_enabled " : False , " Profile_image_url " : " HTTP: \ // a1.twimg.com \/profile_images \/1093534248 \/sign11442542_128x128_normal.jpg " , " Profile_use_background_image " : True , " Statuses_count " : 39 , " Profile_background_color " : " C0deed " , " Followers_count " : 4 , " Description " : " Programmer, tour, Table Tennis " , " Screen_name " : " Jack_cai " , " Listed_count " : 0 , " Verified " : False , " Profile_background_image_url " : " HTTP: \/a3.twimg.com \/A \/1299696992 \/images \/themes \/theme1 \/bg.png " , " Location " : " Shenzhen " , " Time_zone " : " Hong Kong " , " Profile_text_color " : " 333333 " , " Is_translator " : False , " Lang " : " En " , " Profile_sidebar_fill_color " : " Ddeef6 " , " Protected " : False , " Id_str " : " 71195487 " , " Default_profile_image " : False , " Default_profile " : True , " Profile_background_tile " : False , " Created_at " : " Thu Sep 03 07:10:38 + 0000 2009 " , " Name " : " Jack Cai " , " Friends_count " : 13 , " URL " : " HTTP: \/chy710.cnblogs.com \/ " , " ID " : 71195487 , " Following " : Null , " Utc_offset " : 28800 , " Favourites_count " : 0 , " Profile_link_color " : " 0084b4 " }, " Retweeted " : False , " ID " : 52910061479133184 , " In_reply_to_user_id_str " : Null , " Coordinates " : Null , " GEO " : Null , " Retweet_count " : 0 }

{ " Delete " :{ " Status " :{ " User_id_str " : " 71195487 " , " Id_str " : " 52910061479133184 " , " ID " : 52910061479133184 , " User_id " : 71195487 }}}

 

User streams

This module subscribes to the status of the current user and updates information such as "follow" and "add to Favorites". The update content received for the first time after the connection is created is the list of friend IDs of the user.

{ " Friends " :[ 1497 , 169686021 , 790205 , 15211564 , 37784836 , 821958 , 14884312 , 92015003 , 822571 , 63846421 ...]}

Subsequent Updates are user-related content updates (same as streaming). For example, when you or your friends update the status, when you follow someone or someone follows you, when you add a message to favorites or someone adds your message to favorites .. And so on.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.