update to PHP-8.1
[m6w6/seekat] / examples / promise.php
index cee5c74a9652bb2d66392a8f3d6f6e3afc3845fe..b39890d8d51158bc21af4f350dd57724dd9c0973 100755 (executable)
@@ -1,23 +1,19 @@
 #!/usr/bin/env php
 <?php
 
-require_once __DIR__."/../vendor/autoload.php";
+$api = include "examples.inc";
 
-use seekat\API;
-
-$api = new API(API\Future\amp(), API\auth("token", getenv("GITHUB_TOKEN")));
-
-$api->users->m6w6->gists()->when(function($error, $gists) {
+$api->users->m6w6->gists()->onResolve(function($error, $gists) {
        $error and die($error);
        foreach ($gists as $gist) {
-               $gist->commits()->when(function($error, $commits) use($gist) {
+               $gist->commits()->onResolve(function($error, $commits) use($gist) {
                        $error and die($error);
                        foreach ($commits as $i => $commit) {
                                if (!$i) {
                                        printf("\nGist %s, %s:\n", $gist->id, $gist->description ?: "<no title>");
                                }
                                $cs = $commit->change_status;
-                               printf("\t%s: ", substr($commit->version,0,8));
+                               printf("\t%s: ", substr($commit->version, 0, 8));
                                printf("-%s+%s=%s\n", $cs->deletions, $cs->additions, $cs->total);
                        }
                });