Answer the question
In order to leave comments, you need to log in
How to get data when logged into fb?
I inserted a facebook login widget into my site. In the view, I want to get the display of the user's first and last name, but after I logged in, nothing happens.
Controller:
public function actions()
{
return [
'auth' => [
'class' => 'yii\authclient\AuthAction',
'successCallback' => [$this, 'oAuthSuccess'],
],
];
}
public function oAuthSuccess($client) {
// get user data from client
$userAttributes = $client->getUserAttributes();
return $this->render('say',['first_name' => $userAttributes['first_name'],'last_name' => $userAttributes['last_name'], ]);
// do some thing with user data. for example with $userAttributes['email']
}
<?php
use yii\helpers\Html;
?>
<?= Html::encode($first_name) ?>
<?= Html::encode($last_name) ?>
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