Answer the question
In order to leave comments, you need to log in
How to get VK id, users on your site?
Hello, how to get the VK id of those users who click on the subscribe to the newsletter button on the site? This is necessary so that I can send them a mailing list in HP.
I created a Standalone application, I understood how to send messages, the problem is getting the user id.
I tried to do it through authorization, but I don’t understand where I get the answer with id and email?
https://oauth.vk.com/authorize?client_id=0000000&scope=email&display=popup
Answer the question
In order to leave comments, you need to log in
First send the user to this url
$params = [
'client_id' => 'ваш app_id',
'redirect_uri' => 'http://site.tld/vk.php',
'display' => 'page',
'scope' => 'email',
'response_type' => 'code',
'v' => '5.60',
];
$url = 'https://oauth.vk.com/authorize?' . http_build_query($params, null, '&');
$params = [
'client_id' => 'ваш app_id',
'client_secret' => 'ваш app secret',
'redirect_uri' => 'http://site.tld/vk.php',
'code' => $_GET['code'],
];
$token = file_get_contents('https://oauth.vk.com/access_token?' . http_build_query($params, null, '&'));
//ответ будет такой {"access_token":"****","expires_in":"*****","user_id":"*****","email":"****"}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question