Answer the question
In order to leave comments, you need to log in
Getting a token?
I can’t find the problem, everything stops to receive the code, we get the code and get a link like: site.ru/sign-vk
?
if(isset($_GET['code'])){
$params = array(
'client_id' => $clientId,
'client_secret' => $clientSecret,
'code' => $_GET['code'],
'redirect_uri' => $redirectUri
);
$response = json_decode(file_get_contents('https://oauth.vk.com/access_token?'.http_build_query($params)));
$token = $response -> access_token; // Токен
$expiresIn = $response -> expires_in; // Время жизни токена
$userId = $response -> user_id; // ID пользователя
$email = $response -> email; // EMAIL пользователя
$_SESSION['vkuid'] = $userId;
$_SESSION['token'] = $token;
$_SESSION['email'] = $email;
}
Answer the question
In order to leave comments, you need to log in
I solved the problem, but I did not understand where it came from and what it was. Might be useful for someone in the future:
if(isset($_GET['code'])){
$params = array(
'client_id' => $clientId,
'client_secret' => $clientSecret,
'code' => $_GET['code'],
'redirect_uri' => $redirectUri
);
$content = file_get_contents('https://oauth.vk.com/access_token?' . http_build_query($params));
$response = json_decode($content);
$token = $response -> access_token; // Токен
$expiresIn = $response -> expires_in; // Время жизни токена
$userId = $response -> user_id; // ID пользователя
$email = $response -> email; // EMAIL пользователя
$_SESSION['vkuid'] = $userId;
$_SESSION['token'] = $token;
$_SESSION['email'] = $email;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question