PHP Classes

An example how to get VK email, please implement in the class

Recommend this page to a friend!

      PHP OAuth Library  >  PHP OAuth Library package blog  >  Learn with a PHP OAut...  >  All threads  >  An example how to get VK email,...  >  (Un) Subscribe thread alerts  
Subject:An example how to get VK email,...
Summary:Regarding this example please consider to add to the class
Messages:3
Author:Sebas
Date:2017-08-20 15:27:46
 

  1. An example how to get VK email,...   Reply   Report abuse  
Picture of Sebas Sebas - 2017-08-20 15:27:46
Hello Manuel,

Here is example hot to get VK email, I hope you can implement it to your awesome class!

First of all in the scope add email string - 'scope'=>'email'

if(isset($_GET['code'])){
$params = array(
'client_id' => $this->clientId,
'client_secret' => $this->clientSecret,
'code' => $_GET['code'],
'redirect_uri' => $this->redirectUri
);
$tokenInfo = $this->get('https://oauth.vk.com/access_token', $params);

and now User's email is located in $tokenInfo['email'];

For some reason VK giving user's email in the token response.

  2. Re: An example how to get VK email,...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2017-08-20 20:19:42 - In reply to message 1 from Sebas
Yes, the class can also retrieve the token response and store it for further usage.

I just changed the VK OAuth configuration to make it store the access token response.

I also changed the example script to set the token scope to get the email and display the access token response so you can see the email and other token response values you may need.

  3. Re: An example how to get VK email,...   Reply   Report abuse  
Picture of Sebas Sebas - 2017-08-20 21:13:01 - In reply to message 2 from Manuel Lemos
Thank you so much!