本文整理匯總了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;
}