howyi / twitter-monitor
Twitter Stream monitoring tool
v1.0.1
2018-01-05 05:44 UTC
Requires
- php: >=7.1
- abraham/twitteroauth: ^0.7.4
- howyi/service-monitor: ~1.0.0
- spatie/twitter-streaming-api: ^1.0.0
Requires (Dev)
- mockery/mockery: ^1.0
- phpspec/prophecy: ^1.7
- phpstan/phpstan: ^0.8.0
- phpunit/phpunit: ^6.2
- satooshi/php-coveralls: ^1.0
- squizlabs/php_codesniffer: ^3.0
- symfony/var-dumper: ^3.3
This package is auto-updated.
Last update: 2025-01-25 20:26:47 UTC
README
Twitter Stream monitoring tool
Start monitoring
// Return the greeting bot $monitor = new \ServiceMonitor\Twitter\UserStreamMonitor( getenv('TWITTER_ACCESS_TOKEN'), getenv('TWITTER_ACCESS_TOKEN_SECRET'), getenv('TWITTER_CONSUMER_KEY'), getenv('TWITTER_CONSUMER_SECRET') ); $event = new class extends \ServiceMonitor\Twitter\TwitterEvent { public function isExecutable(array $value): bool { if (!isset($value['in_reply_to_user_id_str']) or !isset($value['text'])) { return false; } if ($value['in_reply_to_user_id_str'] !== $this->self->id_str) { return false; } return (strpos($value['text'], 'hello') !== false); } public function execute(array $value): void { echo("User:@{$value['user']['screen_name']} greeted :)" . PHP_EOL); $status = "Hello, @{$value['user']['screen_name']} !"; $this->connection->post( 'statuses/update', ['in_reply_to_status_id'=> $value['id_str'], 'status' => $status] ); } }; $monitor->setEvent($event); $monitor->start();