How To Process Tweets in Real-Time with Laravel
Daniel Abernathy has written a nice tutorial about how to create a Laravel app that connects to the Twitter Streaming API.
This tutorial will show how to use the Twitter Streaming APIs to process tweets in real-time from a Laravel application. There are a variety of use cases for this: perhaps you want to auto-respond to mentions of your company, run a contest via Twitter, or create support tickets when users complain about your product. For this tutorial, we'll build a "featured tweets" widget to display approved tweets on our app's home page.
You might first look at the Twitter REST APIs, which many developers are familiar with. These APIs allow you to do a lot of cool things: read and write tweets on behalf of app users, manage followers and lists, and more. However, if you want to process tweets as they are sent, the REST APIs are very difficult to manage. Pagination and rate limiting become a logistical nightmare quickly.
Whereas the REST APIs force you to request information, the Streaming APIs feed information to you. You can read more about how it works in the documentation, but it's basically a pipe from Twitter to your application which delivers a continual flow of tweets.
By the end of the tutorial, you'll have a constantly updating collection of tweets in your app that you can approve or disapprove to show up in your home page. Here's a preview of what you'll end up with.
Public Streaming API: There are three Streaming APIs, but the one we care about is the Public API - and more specifically, the 'filter' endpoint. This endpoint will deliver a stream of all public tweets, filtered by the keywords tha
This post is submitted by one of our members. You may submit a new post here.