forked from felixdorn/twitter-stream-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tinker.php
41 lines (30 loc) · 986 Bytes
/
tinker.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
use NunoMaduro\Collision\Provider;
use RWC\TwitterStream\Connection;
use RWC\TwitterStream\FilteredStream;
use RWC\TwitterStream\RuleBuilder;
use RWC\TwitterStream\RuleManager;
require __DIR__ . '/vendor/autoload.php';
(new Provider())->register();
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();
$bearerToken = $_ENV['TWITTER_BEARER_TOKEN'];
$stream = new FilteredStream();
// Rule::deleteBulk(...Rule::all());
// RuleBuilder::create('cats')->save();
$connection = new Connection($bearerToken);
$rule = new RuleManager($connection);
$res = $rule->new('cat videos but no images')
->group(fn (RuleBuilder $builder) => $builder->query('cats'))
->hasVideos()
->save();
dd($res->getBody()->getContents(), $res->getStatusCode());
//
// $stream
// ->listen(new Connection($bearerToken), function (object $tweet) {
// dump($tweet);
// });
//
// foreach ($twitterStream->filteredTweets() as $tweet) {
// dump($tweet);
// }