PHP code example of killmails / oauth2-eve

1. Go to this page and download the library: Download killmails/oauth2-eve library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

killmails / oauth2-eve example snippets


use Killmails\OAuth2\Client\Provider\EveOnline;

$sso = new EveOnline([
    'clientId' => '{eveonline-client-id}',
    'clientSecret' => '{eveonline-client-secret}',
    'redirectUri' => 'https://example.com/callback-url',
]);

if (empty($_GET['code'])) {
    $url = $sso->getAuthorizationUrl();
    $_SESSION['state'] = $sso->getState();

    header('Location: '.$authUrl);
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['state'])) {
    unset($_SESSION['state']);
} else {
    $token = $sso->getAccessToken('authorization_code', [
        'code' => $_GET['code']
    ]);

    $user = $sso->getResourceOwner($token);

    printf('Hello, %s (%d)', $user->getName(), $user->getId());
}

$options = [
    'scope' => ['esi-killmails.read_killmails.v1']
];

$url = $sso->getAuthorizationUrl($options);

// ...