How To Read Twitter Stream With PHP and Laravel

A couple of days ago we came across a cool feature from Microsoft Edge that lets you report browser bugs via Twitter.

It works like this, all of the messages that contain the hashtag #EdgeBug would open a new issue. Pretty simple right? How hard would it be to write something like that for your next GitHub project? Seems it’s easier than you thought.

This tutorial will consist of two parts. The first part will teach you how to listen to a Twitter stream that contains a certain keyword and in the next tutorial we’ll show you how easy it is to interact with Github.

Ok, you’ll need guzzle for this, but you probably already have it installed. In case you don’t, here’s how you install the requirements.

composer require guzzlehttp/guzzle and composer require guzzlehttp/oauth-subscriber

There you go, now let’s start with creating a command that will watch for a certain keyword and print it out. In the second part of the tutorial, instead of printing it out, we’ll open a GitHub issue.

php artisan make:console WatchTwitterStream

And here’s what goes into the command:

Originally published at