當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。