/** * * @return Gw2Account */ public function getAccount() { if (!isset($this->account)) { $this->account = Gw2Account::getInstance($this->getToken()); } return $this->account; }
/** * */ public function routeAccountReplaceToken() { $trans = Translator::getInstance(); if ($this->user && $this->isOwner) { $token = $this->getService()->getRequest()->get('token'); $user = User::findByToken($token); if ($user) { if ($user->getCode() == $this->user->getCode()) { return new ResponseJson(['error' => $trans->trans('error.token-is-same')]); } else { return new ResponseJson(['error' => $trans->trans('error.token-already-exists')]); } } try { $account = Gw2Account::getInstance($token); if (empty($account->getName())) { throw new InvalidTokenException(); } if ($this->user->getAccount()->getName() !== $account->getName()) { return new ResponseJson(['error' => $trans->trans('error.mismatch-account')]); } $this->user->setToken($token); $this->user->save(); return new ResponseJson(['ok' => true]); } catch (InvalidTokenException $e) { return new ResponseJson(['error' => $trans->trans('error.invalid-token')]); } } return new ResponseJson(['error' => $trans->trans('error.not-owner')]); }
<?php /* * This file is part of the Arnapou FileStore package. * * (c) Arnaud Buathier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ include __DIR__ . '/../vendor/autoload.php'; use Arnapou\GW2Tools\Service; Service::getInstance(); $account = \Arnapou\GW2Tools\Gw2Account::getInstance('DEA69D98-AD5C-DA4E-9C0A-BB0B4E2BDD16FCD2DF87-E4DF-42D3-BA18-1AE0B1F25B85'); $char = $account->getCharacter('Tao Lympik'); $attrs = $char->getAttributes(); echo "\n\n";