58 lines
1.7 KiB
PHP
58 lines
1.7 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace WoWPress\Api;
|
||
|
|
||
|
class BattleNet extends Api{
|
||
|
|
||
|
|
||
|
protected $api_url = "https://eu.api.blizzard.com";
|
||
|
|
||
|
|
||
|
public function getCharacter($name,$realm,int $timeout=360){
|
||
|
$name = urlencode(strtolower($name));
|
||
|
$realm = urlencode(strtolower($realm));
|
||
|
|
||
|
$data = $this->get("/profile/wow/character/$realm/$name", [
|
||
|
'namespace' => 'profile-eu',
|
||
|
'locale' => 'en_US',
|
||
|
'access_token' => $this->bearer()
|
||
|
], false, $timeout);
|
||
|
|
||
|
return $data;
|
||
|
}
|
||
|
|
||
|
public function getGuildRank($name,$realm){
|
||
|
$char = $this->getCharacter($name,$realm);
|
||
|
$guild = $char['guild']['key']['href'];
|
||
|
|
||
|
$data = $this->get($guild, [
|
||
|
'namespace' => 'profile-eu',
|
||
|
'locale' => 'en_US',
|
||
|
'access_token' => $this->bearer()
|
||
|
], false, -1);
|
||
|
$data = $this->get($data['roster']['href'], [
|
||
|
'namespace' => 'profile-eu',
|
||
|
'locale' => 'en_US',
|
||
|
'access_token' => $this->bearer()
|
||
|
], false, -1);
|
||
|
foreach($data['members'] as $member){
|
||
|
if($member['character']['name'] == $name && $member['character']['realm']['slug'] == $char['realm']['slug']){
|
||
|
return intval($member['rank']);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
public function getMedia($name,$realm,int $timeout=360){
|
||
|
$name = urlencode(strtolower($name));
|
||
|
$realm = urlencode(strtolower($realm));
|
||
|
$data = $this->get("/profile/wow/character/$realm/$name/character-media", [
|
||
|
'namespace' => 'profile-eu',
|
||
|
'locale' => 'en_US',
|
||
|
'access_token' => $this->bearer()
|
||
|
], false, $timeout);
|
||
|
|
||
|
return $data;
|
||
|
}
|
||
|
|
||
|
}
|