navarr / minecraft-api
用于验证Minecraft用户与Mojang服务器的API
2.0
2014-04-10 02:11 UTC
Requires
- php: >=5.3.0
- ext-curl: *
This package is auto-updated.
Last update: 2024-09-12 03:43:43 UTC
README
用PHP编写的用于验证用户与Mojang服务器的API
安装
假设您已安装composer,
php composer.phar require navarr/minecraft-api:2.*
如何使用
在PHP中使用MinecraftAPI非常简单。假设您已经通过composer安装了它,
<?php // composer autoload call use Navarr\MinecraftAPI\MinecraftAPI; use Navarr\MinecraftAPI\Exception\BadLoginException; use Navarr\MinecraftAPI\Exception\MigrationException; use Navarr\MinecraftAPI\Exception\BasicException; try { $minecraftApi = new MinecraftAPI($username, $password); } catch (BadLoginException $e) { // Invalid Credentials } catch (MigrationException $e) { // User tried to login with their minecraft name instead of their mojang account handle (and have migrated) } catch (BasicException $e) { // The account is a "basic" Minecraft account. They have not purchased Minecraft. } $minecraftName = $minecraftApi->username; $accessToken = $minecraftApi->accessToken; $uuid = $minecraftApi->minecraftID;
许可
MIT许可(即将推出!)