当前位置: 首页>>代码示例>>PHP>>正文


PHP ClientInterface::getEmail方法代码示例

本文整理汇总了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;
 }
开发者ID:88c,项目名称:yii2-user,代码行数:13,代码来源:Account.php

示例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;
 }
开发者ID:wangwillout,项目名称:yii2-user,代码行数:30,代码来源:Account.php


注:本文中的yii\authclient\ClientInterface::getEmail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。