From a4dad11be52ca5268b1cfe5f25f916edf5d896c7 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Thu, 21 Jul 2016 19:12:55 +0300 Subject: [PATCH] =?UTF-8?q?Upgrade=20Guzzle=20=D0=B4=D0=BE=206=20=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D1=81=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/components/Mojang/Api.php | 15 ++++++++------- composer.json | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/common/components/Mojang/Api.php b/common/components/Mojang/Api.php index 2fb6360..24bf8d2 100644 --- a/common/components/Mojang/Api.php +++ b/common/components/Mojang/Api.php @@ -18,22 +18,19 @@ class Api { * @url http://wiki.vg/Mojang_API#Username_-.3E_UUID_at_time */ public function usernameToUUID($username, $atTime = null) { - $client = $this->createClient(); - $request = $client->createRequest('GET', 'https://api.mojang.com/users/profiles/minecraft/' . $username); - $queryParams = []; + $query = []; if ($atTime !== null) { - $queryParams['atTime'] = $atTime; + $query['atTime'] = $atTime; } - $request->setQuery($queryParams); - $response = $client->send($request); + $response = $this->createClient()->get($this->buildUsernameToUUIDRoute($username), $query); if ($response->getStatusCode() === 204) { throw new NoContentException('Username not found'); } elseif ($response->getStatusCode() !== 200) { throw new MojangApiException('Unexpected request result'); } - $data = $response->json(['object' => false]); + $data = json_decode($response->getBody(), true); $responseObj = new UsernameToUUIDResponse(); $responseObj->id = $data['id']; $responseObj->name = $data['name']; @@ -47,4 +44,8 @@ class Api { return new GuzzleClient(); } + protected function buildUsernameToUUIDRoute($username) { + return 'https://api.mojang.com/users/profiles/minecraft/' . $username; + } + } diff --git a/composer.json b/composer.json index 46ae60d..1580750 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "ramsey/uuid": "~3.1", "league/oauth2-server": "~4.1.5", "yiisoft/yii2-redis": "~2.0.0", - "guzzlehttp/guzzle": "~5.3.0", + "guzzlehttp/guzzle": "^6.0.0", "php-amqplib/php-amqplib": "~2.6.2", "ely/yii2-tempmail-validator": "~1.0.0", "emarref/jwt": "~1.0.0"