/**
  * @param GithubService $api
  * @param $accessResponse
  */
 function processAddEmail(GithubService $api, $accessResponse)
 {
     $newEmail = getVariable('email');
     $emailCommand = $api->addUserEmails(new Oauth2Token($accessResponse->accessToken), [$newEmail]);
     $allowedScopes = getAuthorisations();
     if (false) {
         //This isn't working yet.
         $emailCommand->checkScopeRequirement($allowedScopes);
     }
     $emailCommand->execute();
     $request = $emailCommand->createRequest();
     $request->setBody(json_encode([$newEmail]));
     $response = $emailCommand->dispatch($request);
 }
Exemple #2
0
function processAddEmail($accessResponse)
{
    $api = new \AABTest\GithubAPI\GithubAPI(GITHUB_USER_AGENT);
    $newEmail = getVariable('email');
    $emailCommand = $api->addUserEmails('token ' . $accessResponse->accessToken, [$newEmail]);
    $allowedScopes = getAuthorisations();
    $emailCommand->checkScopeRequirement($allowedScopes);
    $emailCommand->execute();
    $request = $emailCommand->createRequest();
    $request->setBody(json_encode(["*****@*****.**"]));
    $response = $emailCommand->dispatch($request);
}