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); }
/** * @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); }
/** * @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); }
/** * @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); }
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); }