本文整理汇总了PHP中yii\authclient\ClientInterface::getEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP ClientInterface::getEmail方法的具体用法?PHP ClientInterface::getEmail怎么用?PHP ClientInterface::getEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\authclient\ClientInterface
的用法示例。
在下文中一共展示了ClientInterface::getEmail方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public static function create(BaseClientInterface $client)
{
/** @var Account $account */
$account = Yii::createObject(['class' => static::className(), 'provider' => $client->getId(), 'client_id' => $client->getUserAttributes()['id'], 'data' => json_encode($client->getUserAttributes())]);
if ($client instanceof ClientInterface) {
$account->setAttributes(['username' => $client->getUsername(), 'email' => $client->getEmail()], false);
}
if (($user = static::fetchUser($account)) instanceof User) {
$account->user_id = $user->id;
}
$account->save(false);
return $account;
}
示例2: create
public static function create(BaseClientInterface $client)
{
//xiaoma update
//qq and sina 's attr has no id
$client_type = $client->getId();
switch ($client_type) {
case 'qq':
$client_id = $client->getUserAttributes()['openid'];
$data = json_encode($client->getUserInfo());
break;
case 'sina':
$client_id = $client->getUserAttributes()['uid'];
$data = json_encode($client->getUserInfo());
break;
default:
$client_id = $client->getUserAttributes()['id'];
$data = json_encode($client->getUserAttributes());
break;
}
/** @var Account $account */
$account = Yii::createObject(['class' => static::className(), 'provider' => $client->getId(), 'client_id' => $client_id, 'data' => $data]);
if ($client instanceof ClientInterface) {
$account->setAttributes(['username' => $client->getUsername(), 'email' => $client->getEmail()], false);
}
if (($user = static::fetchUser($account)) instanceof User) {
$account->user_id = $user->id;
}
$account->save(false);
return $account;
}