我收到类似的错误
未知属性– yii\base\UnknownPropertyException
设置未知属性:yii\authclient\clients\Twitter::requestEmail
每当我包含'requestEmail' => 'true',
在web.php'authClientCollection' => [
中components
时
网页.php
$config = [
.
.
'components' => [
.
.
'authClientCollection' => [
'class' => 'yii\authclient\Collection',
'clients' => [
'twitter' => [
'class' => 'yii\authclient\clients\Twitter',
'requestEmail' => 'true',
'consumerKey' => 'IFK2OMG0rKIFK2Jt4rLvw',
'consumerSecret' => 'ImTprQzaOMG0rKZsZiPDIvwIFK2aOMG0rKZsZiPD',
],
],
],
],
UsersController.php(控制器)
class UsersController extends CommonController
{
.
.
public function actions() {
return [
.
.
'auth' => [
'class' => 'yii\authclient\AuthAction',
'successCallback' => [$this, 'oAuthSuccess'],
],
];
}
.
.
public function oAuthSuccess($client) {
// get user data from client
$userAttributes = $client->getUserAttributes();
var_dump($userAttributes); die;
// do some thing with user data. for example with $userAttributes['email']
}
}
login.php (查看)
.
.
<p class="text-center">
<?= yii\authclient\widgets\AuthChoice::widget([
'baseAuthUrl' => ['/users/users/auth']
]) ?>
</p>
.
.
但是,一旦我'requestEmail' => 'true',
从web.php中省略了这一行。它正在工作。我正在获取所有必需的数据,除了email
. 但是,问题是:我没有让email
用户尝试登录。任何想法,我怎么能得到。任何提示/建议都会对我有很大帮助。谢谢。