Публикую скрипт
<?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->token( "access_token" ); $this->api->refresh_token = $this->token( "refresh_token" ); $this->api->access_token_expires_in = $this->token( "expires_in" ); $this->api->access_token_expires_at = $this->token( "expires_at" ); $this->api->token_user_id = $this->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 = $userInfo['uid']; $this->user->profile->firstName = $userInfo['first_name']; $this->user->profile->displayName = $userInfo['screen_name']; $this->user->profile->photoURL = $userInfo['photo_big']; $this->user->profile->gender = $userInfo['sex']; $this->user->profile->email = $this->api->email; $this->user->profile->emailVerified = $this->api->email; return $this->user->profile; } else { throw new Exception( "User profile request failed! {$this->providerId} returned an invalide response.", 6 ); } } }
Такой вопрос только остался открытым все работает, но не получается подтянуть к профилю email. Так и не понял почему $this->user->profile->email. В первичном запросе к vk api указал параметр scope=email как указано в букваре api. Теперь поидее он должен подтянуться в массиве токена $this->token( «email» ); Но почему то не работает. Может у кого-то есть идеи как исправить