PHP code example of rbadillap / twitterstreaming-laravel

1. Go to this page and download the library: Download rbadillap/twitterstreaming-laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rbadillap / twitterstreaming-laravel example snippets


'providers' => [
	// other service providers..
		
    TwitterStreaming\Laravel\TwitterStreamingServiceProvider::class
],


'TwitterStreaming' => TwitterStreaming\Laravel\Facades\TwitterStreaming::class

// Instead of
(new Tracker)
    ->endpoint(Endpoints\PublicEndpoint::class, 'sample')

// You can call in Laravel
TwitterStreaming::publicSample()

// and continue with the rest of the code


publicFilter()
// alias of endpoint(Endpoints\PublicEndpoint::class, 'filter')

publicSample()
// alias of endpoint(Endpoints\PublicEndpoint::class, 'sample')

user()
// alias of endpoint(Endpoints\UserEndpoint::class)

// this is not necessary
->addExtension(Extensions\Filters::class)

// TwitterStreamingPHP detects automatically if the module are thods to filter tweets
            ->withoutRTs()
            ->withoutReplies()
            ->onlyFromAndroid();
    })


        TwitterStreaming::publicFilter()
            ->parameters([
                'track' => '#realmadrid'
            ])
            ->filters(function ($filters) {
                return $filters
                    ->withoutRTs()
                    ->withoutReplies()
                    ->onlyFromAndroid();
            })
            ->track(function ($tweet) {
                print $tweet->text . ' (' . $tweet->source . ')' . PHP_EOL . PHP_EOL;
            });

        TwitterStreaming::publicFilter()
            ->parameters([
                'track' => '#realmadrid'
            ])
            ->filters(function ($filters) {
                return $filters
                    ->withoutRTs()
                    ->withoutReplies()
                    ->onlyFromAndroid();
            })
            ->track(function ($tweet) {
                // php artisan make:job YourLaravelJob
                $this->dispatch(new YourLaravelJob($tweet));
            });