PHP8
[m6w6/seekat] / examples / gistlog.php
1 #!/usr/bin/env php
2 <?php
3
4 require __DIR__."/../vendor/autoload.php";
5
6
7 $log = new Monolog\Logger("seekat");
8 $log->pushHandler(new Monolog\Handler\StreamHandler(STDERR, Monolog\Logger::WARNING));
9
10 $api = new seekat\API(
11 seekat\API\Future\react(),
12 seekat\API\auth("token", getenv("GITHUB_TOKEN")),
13 null, null, $log
14 );
15
16 $api(function($api) {
17 $gists = yield $api->users->m6w6->gists();
18 while ($gists) {
19 $next = \seekat\API\Links\next($gists);
20
21 foreach ($gists as $gist) {
22 foreach ($gist->files as $name => $file) {
23 if ($name == "blog.md") {
24 $text = $file->raw();
25 $head = $gist->description." ".$gist->created_at;
26 echo "$head\n";
27 echo str_repeat("=", strlen($head))."\n\n";
28 echo trim(yield $text);
29 echo "\n\nThis was my last gistlog, pipe it through \$PAGER if ";
30 echo "you really want to read it or visit https://gistlog.co/m6w6\n";
31 return;
32 }
33 }
34 }
35
36 $gists = yield $next;
37 }
38 });