e1f5b9d4fbd4a3311e322fe2706d6ffa11423928
[m6w6/seekat] / examples / promise.php
1 #!/usr/bin/env php
2 <?php
3
4 require_once __DIR__."/../vendor/autoload.php";
5
6 use seekat\API;
7
8 $api = new API(API\Future\amp(), API\auth("token", getenv("GITHUB_TOKEN")));
9
10 $api->users->m6w6->gists()->onResolve(function($error, $gists) {
11 $error and die($error);
12 foreach ($gists as $gist) {
13 $gist->commits()->onResolve(function($error, $commits) use($gist) {
14 $error and die($error);
15 foreach ($commits as $i => $commit) {
16 if (!$i) {
17 printf("\nGist %s, %s:\n", $gist->id, $gist->description ?: "<no title>");
18 }
19 $cs = $commit->change_status;
20 printf("\t%s: ", substr($commit->version,0,8));
21 printf("-%s+%s=%s\n", $cs->deletions, $cs->additions, $cs->total);
22 }
23 });
24 }
25 });
26
27 $api->send();