mirror of
https://github.com/elyby/accounts.git
synced 2024-12-02 11:41:05 +05:30
Upgrade Guzzle до 6 версии
This commit is contained in:
parent
a91ce6ce82
commit
a4dad11be5
@ -18,22 +18,19 @@ class Api {
|
|||||||
* @url http://wiki.vg/Mojang_API#Username_-.3E_UUID_at_time
|
* @url http://wiki.vg/Mojang_API#Username_-.3E_UUID_at_time
|
||||||
*/
|
*/
|
||||||
public function usernameToUUID($username, $atTime = null) {
|
public function usernameToUUID($username, $atTime = null) {
|
||||||
$client = $this->createClient();
|
$query = [];
|
||||||
$request = $client->createRequest('GET', 'https://api.mojang.com/users/profiles/minecraft/' . $username);
|
|
||||||
$queryParams = [];
|
|
||||||
if ($atTime !== null) {
|
if ($atTime !== null) {
|
||||||
$queryParams['atTime'] = $atTime;
|
$query['atTime'] = $atTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
$request->setQuery($queryParams);
|
$response = $this->createClient()->get($this->buildUsernameToUUIDRoute($username), $query);
|
||||||
$response = $client->send($request);
|
|
||||||
if ($response->getStatusCode() === 204) {
|
if ($response->getStatusCode() === 204) {
|
||||||
throw new NoContentException('Username not found');
|
throw new NoContentException('Username not found');
|
||||||
} elseif ($response->getStatusCode() !== 200) {
|
} elseif ($response->getStatusCode() !== 200) {
|
||||||
throw new MojangApiException('Unexpected request result');
|
throw new MojangApiException('Unexpected request result');
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $response->json(['object' => false]);
|
$data = json_decode($response->getBody(), true);
|
||||||
$responseObj = new UsernameToUUIDResponse();
|
$responseObj = new UsernameToUUIDResponse();
|
||||||
$responseObj->id = $data['id'];
|
$responseObj->id = $data['id'];
|
||||||
$responseObj->name = $data['name'];
|
$responseObj->name = $data['name'];
|
||||||
@ -47,4 +44,8 @@ class Api {
|
|||||||
return new GuzzleClient();
|
return new GuzzleClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function buildUsernameToUUIDRoute($username) {
|
||||||
|
return 'https://api.mojang.com/users/profiles/minecraft/' . $username;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
"ramsey/uuid": "~3.1",
|
"ramsey/uuid": "~3.1",
|
||||||
"league/oauth2-server": "~4.1.5",
|
"league/oauth2-server": "~4.1.5",
|
||||||
"yiisoft/yii2-redis": "~2.0.0",
|
"yiisoft/yii2-redis": "~2.0.0",
|
||||||
"guzzlehttp/guzzle": "~5.3.0",
|
"guzzlehttp/guzzle": "^6.0.0",
|
||||||
"php-amqplib/php-amqplib": "~2.6.2",
|
"php-amqplib/php-amqplib": "~2.6.2",
|
||||||
"ely/yii2-tempmail-validator": "~1.0.0",
|
"ely/yii2-tempmail-validator": "~1.0.0",
|
||||||
"emarref/jwt": "~1.0.0"
|
"emarref/jwt": "~1.0.0"
|
||||||
|
Loading…
Reference in New Issue
Block a user