Публикую скрипт <?php class Hybrid_Providers_vk ex
Публикую скрипт <?php class Hybrid_Providers_vk extends Hybrid_Provider_Model_OAuth2 {
function initialize() {
parent::initialize();
$this->api->authorize_url = "http://oauth.vk.com/authorize";
$this->api->token_url = "https://oauth.vk.com/access_token";
$this->api->sign_token_name = "code";
if( this->token( "access_token" ) ){ this->api->access_token = this->api->refresh_token = this->api->access_token_expires_in = this->api->access_token_expires_at = this->api->token_user_id = this->api->email = $this->token( "email" ); }
}
function getUserProfile() {
if ( $this->api->access_token ) {
$params = array(
'uids' => $this->api->token_user_id,
'fields' => 'uid,first_name,last_name,screen_name,sex,bdate,photo_big',
'access_token' => $this->api->access_token
);
$userInfo = json_decode(file_get_contents('https://api.vk.com/method/users.get' . '?' . urldecode(http_build_query($params))), true);
if (isset($userInfo['response'][0]['uid'])) {
$userInfo = $userInfo['response'][0];
$result = true;
}
}
if (result) { this->user->profile->identifier = this->user->profile->firstName = this->user->profile->displayName = this->user->profile->photoURL = this->user->profile->gender = this->user->profile->email = this->user->profile->emailVerified = this->user->profile;
}
else {
throw new Exception( "User profile request failed! {$this->providerId} returned an invalide response.", 6 );
}
} } Такой вопрос только остался открытым все работает, но не получается подтянуть к профилю email. Так и не понял почему this->token( «email» ); Но почему то не работает. Может у кого-то есть идеи как исправить