本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}