X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fseekat;a=blobdiff_plain;f=examples%2Fpromise.php;h=e1f5b9d4fbd4a3311e322fe2706d6ffa11423928;hp=81c7f10376696a83b734c47863f7946e5098eea3;hb=HEAD;hpb=0dcd2b11631fcf57602514e13fae9d31bbb79000 diff --git a/examples/promise.php b/examples/promise.php index 81c7f10..b39890d 100755 --- a/examples/promise.php +++ b/examples/promise.php @@ -1,30 +1,23 @@ #!/usr/bin/env php pushHandler((new Monolog\Handler\StreamHandler(STDERR))->setLevel(Monolog\Logger::INFO)); - -$api = new API([ - "Authorization" => "token ".getenv("GITHUB_TOKEN") -], null, null, $log); - -$api->users->m6w6->gists()->done(function($gists) { +$api->users->m6w6->gists()->onResolve(function($error, $gists) { + $error and die($error); foreach ($gists as $gist) { - $gist->commits()->then(function($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 ?: ""); } $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); } }); } }); -$api->send(); \ No newline at end of file +$api->send();