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