From 06106a2ae5164106d01520aa5029aa5f66545439 Mon Sep 17 00:00:00 2001 From: Stas Pazhoha Date: Thu, 10 Nov 2016 16:41:31 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20OAuth?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/VKApi/OAuth.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/VKApi/OAuth.php b/src/VKApi/OAuth.php index 8fff5a7..ab9c536 100644 --- a/src/VKApi/OAuth.php +++ b/src/VKApi/OAuth.php @@ -1,6 +1,6 @@ "token", "display" => "page", "v" => VkApi::getVersion(), - "redirect_url" => "https://oauth.vk.com/blank.html", + "redirect_uri" => "https://oauth.vk.com/blank.html", "scope" => "wall,friends,groups,photos,offline" ]; if (!is_array($params)) { @@ -51,16 +51,19 @@ public function getCodeLink() public function getTokenByCode($code) { - $params = $this->params; + $params = []; + $params['client_id'] = $this->params['client_id']; + $params['client_secret'] = $this->params['client_secret']; + $params['redirect_uri'] = $this->params['redirect_uri']; $params['code'] = $code; $url = $this->auth_url_token.http_build_query($params); $http = new HttpClient(); $response = $http->get($url); $data = []; if ($response) { - $data = json_decode($response); + $data = json_decode($response, true); } - if (array_key_exists("response", $data)) { + if (array_key_exists("access_token", $data)) { return new VkAccessToken($data); } else { throw new Exception\AuthException($data['error']." - ".$data['error_description'], 1);