publicuhc/php-yggdrasil
Composer 安装命令:
composer require publicuhc/php-yggdrasil
包简介
PHP Library for interacting with Mojang authentication servers
README 文档
README
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('joe@blogs.com');
//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');
统计信息
- 总下载量: 263
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 3
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2014-06-11