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


PHP User::saveOAuthUser方法代码示例

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


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

示例1: new_user

 public function new_user($access_token, $return_url, $display_mode)
 {
     //Facebook provider allows use to request
     //URLs with CURL, but you can use any other way of
     //fetching a URL here.
     $data = $this->provider->getTwitterUser($access_token);
     $data = json_decode($data);
     //Save the new user
     $model = new User($this->pixie);
     $user = $model->saveOAuthUser('tw' . $data->id, $data->id, 'twitter');
     $nameParts = preg_split('/\\s+/', $data->name, -1, PREG_SPLIT_NO_EMPTY);
     $user->first_name = $nameParts[0];
     $user->last_name = $nameParts[1];
     $user->save();
     //Get the 'pixie' role
     /*
            $role=$this->pixie->orm->get('role')
                ->where('name','pixie')
                ->find();
     
            //Add the 'pixie' role to the user
            $fairy->add('roles',$role);
     */
     //Finally set the user inside the provider
     $this->provider->set_user($user, $access_token);
     //And redirect him back.
     $this->return_to_url($display_mode, $return_url);
 }
开发者ID:nchervyakov,项目名称:evolve2,代码行数:28,代码来源:Twitter.php

示例2: new_user

 /**
  * @inheritdoc
  */
 public function new_user($access_token, $return_url, $display_mode)
 {
     $data = $this->provider->request("https://www.googleapis.com/plus/v1/people/me?access_token=" . $access_token);
     $data = json_decode($data, true);
     //Save the new user
     $model = new User($this->pixie);
     $user = $model->saveOAuthUser('gl' . $data['id'], $data['id'], 'google');
     if (is_array($data['emails']) && count($data['emails'])) {
         $user->email = $data['emails'][0]['value'];
     }
     if (is_array($data['name'])) {
         $user->first_name = $data['name']['givenName'];
         $user->last_name = $data['name']['familyName'];
     }
     $user->save();
     //Get the 'pixie' role
     /*
            $role=$this->pixie->orm->get('role')
                ->where('name','pixie')
                ->find();
     
            //Add the 'pixie' role to the user
            $fairy->add('roles',$role);
     */
     //Finally set the user inside the provider
     $this->provider->set_user($user, $access_token);
     //And redirect him back.
     $this->return_to_url($display_mode, $return_url);
 }
开发者ID:nchervyakov,项目名称:evolve2,代码行数:32,代码来源:Google.php

示例3: new_user

 /**
  * @inheritdoc
  */
 public function new_user($access_token, $return_url, $display_mode)
 {
     $config = 'default';
     $data = $this->provider->request("https://api.vk.com/method/users.get?" . "user_id={$this->user_id}" . "&fields=" . implode(',', $this->pixie->config->get("auth.{$config}.login.vkontakte.permissions", array())) . "&v={$this->pixie->config->get("auth.{$config}.login.vkontakte.api_version", 5.2)}" . "&access_token=" . $access_token);
     $data = json_decode($data);
     $data = current($data->response);
     //Save the new user
     $model = new User($this->pixie);
     $user = $model->saveOAuthUser('vk' . $data->id, $data->id, 'vkontakte');
     $user->first_name = $data->first_name;
     $user->last_name = $data->last_name;
     $user->save();
     //Get the 'pixie' role
     /*
            $role=$this->pixie->orm->get('role')
                ->where('name','pixie')
                ->find();
     
            //Add the 'pixie' role to the user
            $fairy->add('roles',$role);
     */
     //Finally set the user inside the provider
     $this->provider->set_user($user, $access_token);
     //And redirect him back.
     $this->return_to_url($display_mode, $return_url);
 }
开发者ID:nchervyakov,项目名称:evolve2,代码行数:29,代码来源:Vkontakte.php

示例4: new_user

 /**
  * @inheritdoc
  */
 public function new_user($access_token, $return_url, $display_mode)
 {
     $data = $this->provider->request("http://api.odnoklassniki.ru/fb.do?" . "method=users.getCurrentUser" . "&access_token=" . $access_token . "&application_key=" . $this->provider->getAppKey() . "&sig=" . $this->provider->getSignature($access_token));
     $data = json_decode($data);
     //Save the new user
     $model = new User($this->pixie);
     $user = $model->saveOAuthUser('ok' . $data->uid, $data->uid, 'odnoklassniki');
     $user->first_name = $data->first_name;
     $user->last_name = $data->last_name;
     $user->save();
     //Get the 'pixie' role
     /*
            $role=$this->pixie->orm->get('role')
                ->where('name','pixie')
                ->find();
     
            //Add the 'pixie' role to the user
            $fairy->add('roles',$role);
     */
     //Finally set the user inside the provider
     $this->provider->set_user($user, $access_token);
     //And redirect him back.
     $this->return_to_url($display_mode, $return_url);
 }
开发者ID:nchervyakov,项目名称:evolve2,代码行数:27,代码来源:Odnoklassniki.php

示例5: new_user

 public function new_user($access_token, $return_url, $display_mode)
 {
     //Facebook provider allows use to request
     //URLs with CURL, but you can use any other way of
     //fetching a URL here.
     $data = $this->provider->request("https://graph.facebook.com/me?access_token=" . $access_token);
     $data = json_decode($data);
     //Save the new user
     $model = new User($this->pixie);
     $user = $model->saveOAuthUser($data->first_name, $data->id, 'facebook');
     //Get the 'pixie' role
     /*
            $role=$this->pixie->orm->get('role')
                ->where('name','pixie')
                ->find();
     
            //Add the 'pixie' role to the user
            $fairy->add('roles',$role);
     */
     //Finally set the user inside the provider
     $this->provider->set_user($user, $access_token);
     //And redirect him back.
     $this->return_to_url($display_mode, $return_url);
 }
开发者ID:brennantom,项目名称:hackazon,代码行数:24,代码来源:Facebook.php


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