function checkAuthResult() { $code = getVariable('code', FALSE); $state = getVariable('state', FALSE); $oauthUnguessable = getSessionVariable('oauthUnguessable', null); if (!$code || !$state || !$oauthUnguessable) { return; } if ($state != $oauthUnguessable) { //Miss-match on what we're tring to validated. echo "Miss-match on secret'"; return; } try { $api = new \AABTest\GithubAPI\GithubAPI(); $command = $api->accessToken(GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET, $code, "http://" . SERVER_HOSTNAME . "/github/return.php"); $response = $command->execute(); setSessionVariable('githubAccess', $response); echo "You are now authed for the following scopes:<br/>"; foreach ($response->scopes as $scope) { echo $scope . "<br/>"; } } catch (\AABTest\GithubAPI\GithubAPIException $fae) { echo "Exception processing response: " . $fae->getMessage(); } }
function showRepoTags(AABTest\Github\AccessResponse $accessResponse, $username, $repo) { $api = new \AABTest\GithubAPI\GithubAPI(GITHUB_USER_AGENT); $command = $api->listRepoTags('token ' . $accessResponse->accessToken, $username, $repo); $repoTags = $command->execute(); foreach ($repoTags->getIterator() as $repoTag) { echo "Tag name: " . $repoTag->name . " sha " . $repoTag->commitSHA . "<br/>"; } }