Download the PHP package zkillboard/eveonlineoauth2 without Composer

On this page you can find all versions of the php package zkillboard/eveonlineoauth2. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package eveonlineoauth2

Eve Online SSO

READ FIRST

Before using this class you must register your application with CCP here:

https://developers.eveonline.com/applications/

There you will register the name and description of your app, provide the callback url, and the scopes you'd like to request. When that is completed you will be provided with the clientID and secretKey you will need for working with Eve Online SSO.

Installation

I recommend using PHP's popular package manager:

composer require zkillboard/eveonlineoauth2

Dependencies

EveOnlineSSO requires the curl extension to be installed. EveOnlineSSO will also install the following:

Implementation

This code was created to make the usage of EveOnlineSSO very simple. Once you have your clientID and secretKey you can instantiate EveOnlineSSO like so:

$sso = new EveOnlineSSO($clientID, $secretKey, $callbackURL, $scopes, $userAgent);

$clientID, $secretKey, $callbackURL, and $userAgent are all strings. The $scopes parameter is an array and defaults to an empty array. If $userAgent is not specified, it will default to the $callbackURL.

Once instantiated, you can then retrieve the URL needed for the user to login with Eve Online SSO:

$loginURL = $sso->getLoginURL($session);

$session can be PHP's $_SESSION, or, an instance of Aura\Session\Segment. More session handling libraries can be added via PR.

A typical web application will then redirect the user to this loginURL. This example will use PHP's header command, but I recommend using a framework such as Slim.

header("Location: $loginURL");

Here the control is out of your hands since the user is verifying their identity with CCP and choosing which character they want to pass back to your application. Once they've completed these steps, the CCP auth server will redirect the user back to your callback URL. Here you will need to do a couple of steps to obtain the user's information.

$sso = new EveOnlineSSO($clientID, $secretKey, $callbackURL, $scopes, $userAgent);
$code = filter_input(INPUT_GET, 'code');
$state = filter_input(INPUT_GET, 'state');
$userInfo = $sso->handleCallback($code, $state, $session);

The resulting $userInfo array will contain the following keys with their appropriate values:

characterID
characterName
scopes
tokenType
refreshToken
accessToken
ownerHash

Keep in mind accessTokens are only good for 20 minutes after creation. If your accessToken has expired, you can use the refreshToken to get a new accessToken:

$sso->getAccessToken($refreshToken);

PLEASE NOTE At the moment, the above call will return a string. This WILL be changing soon and will be returning an Array. CCP will be rotating the refresh tokens at some point, and the above call will return the new refresh token as well. It will be up to your code to handle the new refresh token.

doCall

The doCall method doesn't necessarily have anything to do with SSO but is provided to make it easy and convenient to access authed Eve Online. doCall can handle GET, POST, PUT, DELETE, and OPTIONS.

We'll start off with a simple GET request:

$result = $sso->doCall($url, $fields, $accessToken);

doCall does have a fourth field, which defaults to 'GET', but can be GET, POST, PUT, DELETE, or OPTIONS

$result = $sso->doCall($url, $fields, $accessToken, 'OPTIONS');
$result = $sso->doCall($url, $fields, $accessToken, 'POST');

A rough example for setting the MOTD and free move on a fleet:

$result = $sso->doCall("https://esi.evetech.net/latest/fleets/1043511252862/", ["motd" => "Hi Mom", "isFreeMove" => true], $accessToken, 'PUT');

Or even deleting a squad:

$result = $sso->doCall("https://esi.evetech.net/latest/fleets/1043511252862/wings/2053611252862/squads/3108711252862/", [], $accessToken, 'DELETE');

Each call returns the result as a string which will need to be json_decode'ed by your application. I have left this step out so that your application can json_decode to an object:

$jsonObject = json_decode($result);

or to an array:

$jsonArray = json_decode($result, true);

These calls will also work as a utility for calling the ESI API for scopes that will work on ESI API calls. This is why doCall does not return JSON by default, it is left to the developer to work with the returned data any way they see fit.

That's all there is to it! These simple calls will allow you to get started quickly with Eve Online's SSO and use ESI.

Errors

If the curl call is unsuccessful for any reason it will throw an exception. I recommend properly surrounding your code with try/catch blocks to handle any exceptions. The Eve Online ESI API can and will go down and/or become unresponsive for various reasons (especially during downtime).

Issues

You can either put a use statement at the beginning of your code:

use zkillboard\eveonlineoauth2\eveonlinesso;

or fully qualify the class name when instantiating:

$sso = new \zkillboard\eveonlineoauth2\EveOnlineSSO($clientID, $secretKey, $callbackURL, $scopes);

If you do not provide any scopes, or only request the publicData scope, then the call is basically good for authentication only and no refreshToken is needed, therefore the auth server doesn't give out a refreshToken.


All versions of eveonlineoauth2 with dependencies

PHP Build Version
Package Version
Requires ircmaxell/random-lib Version ^1.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package zkillboard/eveonlineoauth2 contains the following files

Loading the files please wait ....