Answer the question
In order to leave comments, you need to log in
How to get data using VK API?
I'm trying to register using the VK API, I want the user to click on the button, confirm that he agrees, of course, the registration went through and he was redirected to the main page.
<div id="login_button" onclick="VK.Auth.login(authInfo);">Войти</div>
<script language="javascript">
VK.init({
apiId: APP_ID
});
function authInfo(response) {
if (response.session) {
window.location.replace("https://oauth.vk.com/authorize?client_id=APP_ID&redirect_uri=http://site.ru/test2.php&response_type=code");
} else {
alert('not auth');
}
}
</script>
if(empty($_GET['code'])) {
echo "это успех!";
} else {
header("location:https://oauth.vk.com/access_token?client_id=APP_ID&client_secret=APP_SECRET&code=".$_GET['code']."&redirect_uri=http://site.ru/test2.php");
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question