Download the PHP package spatie/laravel-twitter-streaming-api without Composer
On this page you can find all versions of the php package spatie/laravel-twitter-streaming-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download spatie/laravel-twitter-streaming-api
More information about spatie/laravel-twitter-streaming-api
Files in spatie/laravel-twitter-streaming-api
Package laravel-twitter-streaming-api
Short Description Easily work with the Twitter Streaming API in a Laravel app
License MIT
Homepage https://github.com/spatie/laravel-twitter-streaming-api
Informations about the package laravel-twitter-streaming-api
Easily work with the Twitter Streaming API in a Laravel app
Twitter provides a streaming API with which you can do interesting things such as listening for tweets that contain specific strings or actions a user might take (e.g. liking a tweet, following someone,...). This package makes it very easy to work with the API.
Here's an example Laravel application with the package pre-installed. It contains an artisan command to kick off the listening process.
Support us
We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.
Installation
You can install the package via composer:
The config file must be published with this command:
It will be published in config/laravel-twitter-streaming-api.php
Getting credentials
In order to use this package you'll need to get some credentials from Twitter. Head over to the Developer Portal on Twitter to create an application.
Once you've created your application, click on the Keys and tokens
tab to retrieve your bearer_token
, api_key
and api_secret_key
.
Usage
Currently, this package works with the public stream and the user stream. Both the PublicStream
and UserStream
classes provide a startListening
function that kicks of the listening process. Unless you cancel it your PHP process
will execute that function forever. No code after the function will be run.
In the example below a facade is used. If you don't like facades you can replace them with
The public stream
The public stream can be used to listen for specific words that are being tweeted.
The first parameter of whenHears
must be a string, or an array containing the word or words you want to listen for. The
second parameter should be a callable that will be executed when one of your words is used on Twitter.
The user stream
Suggestion on how to run in a production environment
When using this in production you could opt to create an artisan command to listen for incoming events from Twitter. You can use Supervisord to make sure that command is running all the time.
A word to the wise
These APIs work in realtime, so they could report a lot of activity. If you need to do some heavy work processing that activity it's best to put that work in a queue to keep your listening process fast.
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
Contributing
Please see CONTRIBUTING for details.
Security
If you've found a bug regarding security please mail [email protected] instead of using the issue tracker.
Credits
- Freek Van der Herten
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-twitter-streaming-api with dependencies
illuminate/support Version ^8.0|^9.0|^10.0|^11.0
spatie/twitter-streaming-api Version ^2.0.0