update to PHP-8.1
[m6w6/seekat] / examples / promise.php
1 #!/usr/bin/env php
2 <?php
3
4 $api = include "examples.inc";
5
6 $api->users->m6w6->gists()->onResolve(function($error, $gists) {
7 $error and die($error);
8 foreach ($gists as $gist) {
9 $gist->commits()->onResolve(function($error, $commits) use($gist) {
10 $error and die($error);
11 foreach ($commits as $i => $commit) {
12 if (!$i) {
13 printf("\nGist %s, %s:\n", $gist->id, $gist->description ?: "<no title>");
14 }
15 $cs = $commit->change_status;
16 printf("\t%s: ", substr($commit->version, 0, 8));
17 printf("-%s+%s=%s\n", $cs->deletions, $cs->additions, $cs->total);
18 }
19 });
20 }
21 });
22
23 $api->send();