/** * @param $code * @return Token */ public function getAccessToken($code = null, $back = null) { if (null !== $code) { $this->code = $code; } $redirectUri = $this->redirectUri; if ($back) { $redirectUri .= '/back/' . base64_encode($back); } if (null === $this->token) { var_dump('code:', $this->code); $url = 'https://oauth.vk.com/access_token' . '?client_id=' . $this->appId . '&client_secret=' . $this->appSecret . '&v=' . self::API_VERSION . '&code=' . $this->code . '&redirect_uri=' . $redirectUri; //. '&redirect_uri=' . $this->redirectUri; $raw = \Yaoi\Http\Client::getInstance('vk')->fetch($url); var_dump('raw:', $url, $raw); $this->token = json_decode($raw); } var_dump('token:', $this->token); return $this->token; }
private function http() { if (null === $this->resourceHttp) { $this->resourceHttp = \Yaoi\Http\Client::getInstance($this->settings->httpClient); } return $this->resourceHttp; }