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


PHP GraphUser::getId方法代码示例

本文整理汇总了PHP中Facebook\GraphUser::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP GraphUser::getId方法的具体用法?PHP GraphUser::getId怎么用?PHP GraphUser::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Facebook\GraphUser的用法示例。


在下文中一共展示了GraphUser::getId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

 /**
  * Create a new user or log them in if they exist
  *
  * @param \Facebook\GraphUser $fb
  * @return bool
  * @throws \Exception
  */
 public function create(\Facebook\GraphUser $fb)
 {
     $email = $fb->getId() . '@fb';
     $user = $this->db->select('*')->from(':user')->where(['email' => $email])->get();
     if (isset($user['user_id'])) {
         $_password = $fb->getId() . uniqid();
         $password = (new \Core\Hash())->make($_password);
         $this->db->update(':user', ['password' => $password], ['user_id' => $user['user_id']]);
     } else {
         $_password = $fb->getId() . uniqid();
         $password = (new \Core\Hash())->make($_password);
         $id = $this->db->insert(':user', ['user_group_id' => NORMAL_USER_ID, 'email' => $email, 'password' => $password, 'full_name' => $fb->getFirstName() . ' ' . $fb->getLastName(), 'user_name' => 'fb-' . $fb->getId(), 'user_image' => '{"fb":"' . $fb->getId() . '"}', 'joined' => PHPFOX_TIME, 'last_activity' => PHPFOX_TIME]);
         $tables = ['user_activity', 'user_field', 'user_space', 'user_count'];
         foreach ($tables as $table) {
             $this->db->insert(':' . $table, ['user_id' => $id]);
         }
     }
     \User_Service_Auth::instance()->login($email, $_password, true, 'email');
     if (!\Phpfox_Error::isPassed()) {
         throw new \Exception(implode('', \Phpfox_Error::get()));
     }
     return true;
 }
开发者ID:Jinkers,项目名称:phpfox-facebook,代码行数:30,代码来源:Service.php

示例2: getUserFromFacebook

 /**
  * Retourne un utilisateur de la base en fonction de l'utilisateur facebook
  * Si il n'existe pas, on en créée un
  * @param  GraphUser $user [description]
  * @return [type]          [description]
  */
 public function getUserFromFacebook(GraphUser $user)
 {
     $email = $user->getEmail();
     if (is_null($email)) {
         throw new \Exception('Facebook user does not share email', 400);
     }
     // Get user from email
     $fos_user = $this->user_manager->findUserByEmail($email);
     // Create user if necessary
     if (is_null($fos_user)) {
         $fos_user = $this->user_manager->createUser();
     }
     $fos_user->setEnabled(true);
     $fos_user->setEmail($email);
     $fos_user->setFirstName($user->getFirstName());
     $fos_user->setLastName($user->getLastName());
     $fos_user->setRoles([$this->user_role]);
     $fos_user->setFacebookId($user->getId());
     $fos_user->setLocale(substr($user->getProperty('locale'), 0, 2));
     $fos_user->setTimezone($user->getTimezone());
     $this->user_manager->updateCanonicalFields($fos_user);
     $this->user_manager->updateUser($fos_user);
     return $fos_user;
 }
开发者ID:studiocaramia,项目名称:redking_OAuthBundle,代码行数:30,代码来源:UserRegistrator.php

示例3: facebookRegister

 /**
  * Register user using facebook data. It will also check if email already exists and it will update that user.
  * @param GraphUser $me
  * @return User|null
  */
 public static function facebookRegister(GraphUser $me)
 {
     // 1. check if email already exists.
     $old = self::findByAttributes(array('email' => $me->getEmail()));
     if ($old) {
         /* @var $old User */
         $old->fb_id = $me->getId();
         if ($old->status == self::STATUS_NEW) {
             $old->status = self::STATUS_ACTIVE;
         }
         $old->save(false);
         UserConfig::set('FACEBOOK_NAME', $me->getFirstName() . ' ' . $me->getMiddleName() . ' ' . $me->getLastName(), $old->id);
         UserConfig::set('FACEBOOK_EMAIL', $me->getProperty('email'), $old->id);
         UserConfig::set('FACEBOOK_PROFILE', $me->getLink(), $old->id);
         return $old;
     }
     $user = new User();
     $user->fb_id = $me->getId();
     $user->email = $me->getProperty('email');
     $user->register_date = date('Y-m-d H:i:s');
     $user->status = self::STATUS_ACTIVE;
     $user->save(false);
     UserConfig::set('FACEBOOK_NAME', $me->getFirstName() . ' ' . $me->getMiddleName() . ' ' . $me->getLastName(), $user->id);
     UserConfig::set('FACEBOOK_EMAIL', $me->getProperty('email'), $user->id);
     UserConfig::set('FACEBOOK_PROFILE', $me->getLink(), $user->id);
     return $user;
 }
开发者ID:mpf-soft,项目名称:app-basic,代码行数:32,代码来源:User.php

示例4: createFacebookUser

 /**
  * OVERRIDE THIS IF NECESSARY
  *
  * @param GraphUser $facebook_user
  */
 public function createFacebookUser(GraphUser $facebook_user)
 {
     $fb_id_field = \Config::get('api-foundation::user_table_fb_id_field');
     $login_type_field = \Config::get('api-foundation::user_table_login_type_field');
     $login_type_facebook = \Config::get('api-foundation::user_table_login_type_facebook');
     $user = new OAuthUser();
     $user->email = $facebook_user->getProperty('email');
     $user->password = Hash::make(str_random(20));
     $user->{$fb_id_field} = $facebook_user->getId();
     $user->first_name = $facebook_user->getFirstName();
     $user->last_name = $facebook_user->getLastName();
     $user->{$login_type_field} = $login_type_facebook;
     $user->save();
 }
开发者ID:shaunpersad,项目名称:api-foundation,代码行数:19,代码来源:ModelStorage.php


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