Coder Social home page Coder Social logo

games647 / php-yggdrasil Goto Github PK

View Code? Open in Web Editor NEW

This project forked from eluinhost/php-yggdrasil

0.0 3.0 0.0 49 KB

PHP Library for interacting with Mojang authentication servers

Home Page: https://packagist.org/packages/publicuhc/php-yggdrasil

License: GNU General Public License v3.0

PHP 100.00%
minecraft authentication library client

php-yggdrasil's Introduction

php-yggdrasil

SensioLabsInsight

PHP Library for interacting with Mojang authentication servers.

Installation

Using composer add it to your requirements section:

{
    "require-dev": {
        "publicuhc/php-yggdrasil": "dev-master"
    }
}

Usage

First you need to get hold of a Yggdrasil instance, the only choice right now is DefaultYggdrasil

$yggdrasil = new DefaultYddrasil();

You can also pass the username/clientToken/accessToken in the constructor if needed, or alternatively use the setter methods.

You can then use the Yggdrasil instance to query against the server:

//set the username
$yggdrasil->setUsername('[email protected]');

//authenticate with the password, sets accessToken/clientToken on success
$yggdrasil->authenticate('joeisthebest');

$clientToken = $yggdrasil->getClientToken();
$accessToken = $yggdrasil->getAccessToken();

Error Checking

All API functions can throw the following:

APIRequestException

Thrown when the mojang servers returned errors for the request, the short error can be found at $ex->getShortMessage(), the full message can get found at $ex->getMessage(), and the cause (if set) can be found at $ex->getCause()

InvalidParameterException

Thrown when an API method was called and certain parameters were not set yet. e.g.

//username not set yet
$yg = new DefaultYggdrasil();

//will throw InvalidParameterException due to username not being set
$yg->authenticate('xxx');

$yg->setUsername('yyy');

//will run correctly
$yg->authenticate('xxx');

php-yggdrasil's People

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.