1. Go to this page and download the library: Download spatie/twitter-labs 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/ */
spatie / twitter-labs example snippets
public function asyncAddRule(\Spatie\TwitterLabs\FilteredStream\Rule $rule): PromiseInterface;
public function asyncAddRules(\Spatie\TwitterLabs\FilteredStream\Rule ...$rules): PromiseInterface;
public function asyncDeleteRules(string ...$ruleIds): PromiseInterface;
public function asyncSetRules(\Spatie\TwitterLabs\FilteredStream\Rule ...$rules): PromiseInterface;
public function asyncGetRules(): PromiseInterface;
public function addRule(\Spatie\TwitterLabs\FilteredStream\Rule $rule): \Spatie\TwitterLabs\FilteredStream\Responses\Rules\AddRulesResponse;
public function addRules(\Spatie\TwitterLabs\FilteredStream\Rule ...$rules): \Spatie\TwitterLabs\FilteredStream\Responses\Rules\AddRulesResponse;
public function deleteRules(string ...$ruleIds): \Spatie\TwitterLabs\FilteredStream\Responses\Rules\DeleteRulesResponse;
public function setRules(\Spatie\TwitterLabs\FilteredStream\Rule ...$rules): \Spatie\TwitterLabs\FilteredStream\Responses\Rules\ListRulesResponse;
public function getRules(): \Spatie\TwitterLabs\FilteredStream\Responses\Rules\ListRulesResponse;
use Spatie\TwitterLabs\FilteredStream\FilteredStreamFactory;
use Spatie\TwitterLabs\FilteredStream\Rule;
FilteredStreamFactory::create('token', 'secret')
->addRule(new Rule('@spatie_be', 'mentioning_spatie'));
use React\EventLoop\Factory;
use Spatie\TwitterLabs\FilteredStream\FilteredStreamFactory;
use Spatie\TwitterLabs\FilteredStream\Rule;
$loop = Factory::create();
FilteredStreamFactory::create('token', 'secret', $loop)
->asyncAddRule(new Rule('@spatie_be', 'mentioning_spatie'));
$loop->run();
use React\EventLoop\Factory;
use Spatie\TwitterLabs\FilteredStream\FilteredStreamFactory;
use Spatie\TwitterLabs\FilteredStream\Rule;
$loop = Factory::create();
FilteredStreamFactory::create('token', 'secret', $loop)
->asyncSetRules(new Rule('cat photos')); // or use `setRules()` synchronously
$loop->run();
use React\EventLoop\Factory;
use Spatie\TwitterLabs\FilteredStream\Responses\Tweet\Tweet;
use Spatie\TwitterLabs\FilteredStream\FilteredStreamFactory;
$loop = Factory::create();
FilteredStreamFactory::create('token', 'secret', $loop)
->onTweet(fn(Tweet $tweet) => print($tweet->text))
->connect();
$loop->run();
use Spatie\TwitterLabs\FilteredStream\Responses\Tweet\Tweet;
use Spatie\TwitterLabs\FilteredStream\FilteredStreamFactory;
FilteredStreamFactory::create('token', 'secret')
->onTweet(fn(Tweet $tweet) => print($tweet->text))
->start();
php
$filteredStream = \Spatie\TwitterLabs\FilteredStream\FilteredStreamFactory::create('twitter api token', 'twitter api secret');
$filteredStream->addRule(
new \Spatie\TwitterLabs\FilteredStream\Rule('cat has:media', 'cat photos')
);
$filteredStream
->onTweet(fn (Tweet $tweet) => print($tweet->text . PHP_EOL))
->start();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.