J
J
jenya77712016-12-25 14:09:49
API
jenya7771, 2016-12-25 14:09:49

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

How to remove the redirect, or do I still need to create a website in VK? Is it right to create 2 applications?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2016-12-25
@jenya7771

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, '&');

vk.php script
$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":"****"}

B
Boris Korobkov, 2017-05-24
@Maxmil

SiteController not found or actionError method in it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question