Answer the question
In order to leave comments, you need to log in
Authorization using Hybridauth. Vkontakte sends ID instead of username?
Good day to all. Site on Wordpress. The Commentator plugin is installed, which uses the Hybridauth library for user authorization. I added the entrance using Vkontakte myself.
Vkontakte.php - Github
Everything works but displays ID instead of name:
function getUserProfile()
{
// refresh tokens if needed
$this->refreshToken();
// Vkontakte requires user id, not just token for api access
$params['uid'] = Hybrid_Auth::storage()->get( "hauth_session.{$this->providerId}.user_id" );
$params['fields'] = implode(',', $this->fields);
// ask vkontakte api for user infos
$response = $this->api->api( 'getProfiles' , 'GET', $params);
if (!isset( $response->response[0] ) || !isset( $response->response[0]->uid ) || isset( $response->error ) ){
throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
}
// Fill datas
$response = reset($response->response);
foreach ($this->getUserByResponse($response, true) as $k => $v)
$this->user->profile->$k = $v;
// Additional data
$this->user->profile->email = Hybrid_Auth::storage()->get( "hauth_session.{$this->providerId}.user_email" );
return $this->user->profile;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question