Building With the Twitter API: Using Real-Time Streams
While the Twitter REST API is suitable for many applications, if you want immediate updates and access to a broader array of notifications, the Twitter Streaming API is essential. For example, only the streaming API will tell you when another user favorites one of your tweets. Using the Streaming API requires a persistent, keep-alive connection between your web server and Twitter. This type of implementation may be unfamiliar to many PHP developers. As soon as tweets come in, Twitter notifies your server in real time, allowing you to store them into your database without the delay of polling the REST API. Use of the Streaming API is also not subject to Twitter's API rate limits. Here's a visualization of how it works: There are three variations of the Twitter Streaming API: The Public Stream. This allows your application to monitor public data on Twitter, such as public tweets, hashtag filters, et al. The User Stream. This allows you to track a user's tweet stream in real t...