redwebcreation/twitter-stream-api
Laravel/PHP package for consuming the Twitter Streaming API. Provides an easy way to connect, authenticate, and listen to real-time tweets/events, letting you filter streams and handle incoming data in your app with minimal setup.
Guzzle or Http client can handle this, but ensure your app’s auth flow (e.g., OAuth tokens) is compatible.text, user, entities) will need custom logic or a library like spatie/array-to-object.twitter-stream:process job).tweets/search/recent) suffice?TweetReceived) to trigger downstream actions (e.g., analytics, notifications).event(new TweetReceived($tweet));
created_at for large-scale deployments.elasticsearch/elasticsearch) or OpenSearch for full-text search.ProcessTweetJob) to handle spikes.$stream->onTweet(function ($tweet) {
ProcessTweetJob::dispatch($tweet);
});
cURL and JSON (standard in PHP). For high throughput, consider openssl for auth..env).guzzlehttp/guzzle:^7.0).predis/predis for pub/sub if needed..env:
TWITTER_CONSUMER_KEY=...
TWITTER_CONSUMER_SECRET=...
TWITTER_ACCESS_TOKEN=...
TWITTER_ACCESS_TOKEN_SECRET=...
use Redwebcreation\TwitterStreamApi\TwitterStream;
$stream = new TwitterStream([
'consumer_key' => env('TWITTER_CONSUMER_KEY'),
'consumer_secret' => env('TWITTER_CONSUMER_SECRET'),
'access_token' => env('TWITTER_ACCESS_TOKEN'),
'access_token_secret' => env('TWITTER_ACCESS_TOKEN_SECRET'),
]);
$stream->onTweet(function ($tweet) {
// Process tweet (e.g., save to DB, dispatch job)
});
$stream->onError(function ($error) {
Log::error("Stream error: " . $error->getMessage());
});
$stream->filter(['track' => 'laravel']); // Keyword filter
// OR
$stream->user('12345'); // User stream
php artisan horizon
redwebcreation/twitter-stream-api and its dependencies (e.g., guzzlehttp/guzzle) in composer.json.composer why-not to audit for vulnerable packages.dd($tweet) or Log::debug() to inspect raw data.#tech, one for #sports).opcache and pcntl for multi-process streams.How can I help you explore Laravel packages today?