本文整理汇总了PHP中Parse\ParseUser::set方法的典型用法代码示例。如果您正苦于以下问题:PHP ParseUser::set方法的具体用法?PHP ParseUser::set怎么用?PHP ParseUser::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parse\ParseUser
的用法示例。
在下文中一共展示了ParseUser::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: signUp
public function signUp($name, $password, $email)
{
$user = new ParseUser();
$user->set("username", $name);
$user->set("password", $password);
$user->set("email", $email);
try {
$user->signUp();
} catch (ParseException $ex) {
echo "Error: " . $ex->getCode() . " " . $ex->getMessage();
}
return $user->get('username');
}
示例2: signup
function signup()
{
$username = $_POST["id"];
$user = new ParseUser();
$user->set("username", $username);
$user->set("password", $_POST["pass"]);
$user->set("email", $username . "@example.com");
try {
$user->signUp();
// Hooray! Let them use the app now.
} catch (ParseException $ex) {
// Show the error message somewhere and let the user try again.
echo "Error: " . $ex->getCode() . " " . $ex->getMessage();
}
}
示例3: createUser
/**
* Creating new user
* @param String $name User full name
* @param String $email User login email id
* @param String $password User login password
*/
public function createUser(CustomParseUser $cpu)
{
$response = array();
// First check if user already existed in db
if (!$this->isUserExists($cpu->getUserName(), $cpu->getEmail())) {
// Generating API key
$api_key = $this->generateApiKey($cpu->getEmail());
$user = new ParseUser();
$user->set("username", $cpu->getUsername());
$user->set("password", $cpu->getPassword());
$user->set("email", $cpu->getEmail());
$user->set("firstName", $cpu->getFirstName());
$user->set("lastName", $cpu->getLastName());
$user->set("birthday", $cpu->getBirthday());
$user->set("apiKey", $api_key);
try {
$user->signUp();
// Hooray! Let them use the app now.
return 'USER_CREATED_SUCCESSFULLY';
} catch (Parse\ParseException $ex) {
// Show the error message somewhere and let the user try again.
echo "Error: " . $ex->getCode() . " " . $ex->getMessage();
return 'USER_CREATE_FAILED';
}
} else {
// User with same email already existed in the db
return 'USER_ALREADY_EXISTED';
}
return $response;
}
示例4: singup
public static function singup($name, $lastname, $email, $password)
{
if (!empty($name) && !empty($lastname) && !empty($email) && !empty($password)) {
$cleanName = filter_var($name, FILTER_SANITIZE_STRING);
$cleanLastName = filter_var($lastname, FILTER_SANITIZE_STRING);
$cleanEmail = filter_var($email, FILTER_SANITIZE_EMAIL);
$cleanPassword = filter_var($password, FILTER_SANITIZE_STRING);
$user = new ParseUser();
$user->set("username", $cleanEmail);
$user->set("password", $cleanPassword);
$user->set("email", $cleanEmail);
$customer = self::createStripeId($cleanEmail);
// other fields can be set just like with ParseObject
$user->set("stripeId", $customer['id']);
$user->set("name", $cleanName);
$user->set("lastname", $cleanLastName);
try {
$user->signUp();
return 200;
} catch (ParseException $ex) {
return 500;
}
} else {
return 500;
}
}
示例5: register
function register($name, $email, $password, $teacher)
{
$user = new ParseUser();
$user->set("username", $email);
$user->set("email", $email);
$user->set("password", $password);
$user->set("name", $name);
if ($teacher == "true") {
$user->set("Teacher", true);
} else {
$user->set("Teacher", false);
}
try {
$user->signUp();
$user->save();
if ($teacher == "true") {
header("Location: profile.php");
} else {
header("Location: howToLearn.php");
}
// Hooray! Let them use the app now.
} catch (ParseException $ex) {
// Show the error message somewhere and let the user try again.
}
}
示例6: reguistraUsuario
/**
* Registra a un usuario nuevo tomando sus datos, si todo fue bien retorna el
* objeto conteniendo al usuario, si no, retorna un mensaje de error.
* @param type $nombre nombre del usuario
* @param type $contraseña su contraseña
* @param type $email el email del usuario
* @param type $tipo el tipo de usuario (1 persona fisica, 2 persona moral).
* @return objeto json
*/
public static function reguistraUsuario($usuario)
{
$user = new ParseUser();
$user->set("username", $usuario->getNombre());
$user->set("password", $usuario->getPassword());
$user->set("email", $usuario->getEmail());
$user->set("tipo", $usuario->getTipo());
try {
$user->signUp();
return json_encode([reg => 1, mensaje => 'Usuario registrado']);
} catch (ParseException $ex) {
if ($ex->getCode() == 203) {
return json_encode([reg => 0, mensaje => "La direccion email " . $usuario->getEmail() . " ya esta ocupada"]);
} else {
if ($ex->getCode() == 202) {
return json_encode([reg => 0, mensaje => "El nombre de usuario " . $usuario->getNombre() . " ya esta ocupado"]);
} else {
return json_encode([reg => 0, mensaje => $ex->getMessage()]);
}
}
}
}
示例7: doAddManager
public function doAddManager($adminfName, $adminlName, $adminMail, $adminPass, $adminPerm)
{
# code...
$currentUser = ParseUser::getCurrentUser();
$dbusername = $this->session->userdata('username');
$userDetails = $this->db->get_where('userdetails', ['username' => $dbusername])->row();
$dbgetusername = $userDetails->username;
$dbgetpassword = $userDetails->password;
$user = new ParseUser();
$user->set("username", $adminMail);
$user->set("password", $adminPass);
$user->set("email", $adminMail);
$user->set("creator", $currentUser);
// other fields can be set just like with ParseObject
$user->set("firstName", $adminfName);
$user->set("lastName", $adminlName);
try {
// Query for the role to be assigned to the owner of the company
$role = new ParseObject("_Role");
$query = new ParseQuery("_Role");
$role = $query->get($adminPerm);
$user->signUp();
$role->getUsers()->add($user);
$user->set("role", $role);
$role->save();
$user->save();
ParseUser::logOut();
$prevUser = ParseUser::logIn($dbgetusername, $dbgetpassword);
// Hooray! Let them use the app now.
return ['status' => true];
} catch (ParseException $ex) {
// Show the error message somewhere and let the user try again.
// echo "Error: " . $ex->getCode() . " " . $ex->getMessage();
return ['status' => false, 'parseMsg' => $ex->getMessage()];
}
}
示例8: processFBLogin
public function processFBLogin(Request $request)
{
$fb = new Facebook(['app_id' => config('facebook.app_id'), 'app_secret' => config('facebook.app_secret'), 'default_graph_version' => 'v2.2']);
$redirect_url = $request->getSchemeAndHttpHost() . '/fblogin';
$code = $request->input('code');
$helper = $fb->getRedirectLoginHelper();
try {
$accessToken = $helper->getAccessToken();
if (!$accessToken->isLongLived()) {
$oAuth2Client = $fb->getOAuth2Client();
// Exchanges a short-lived access token for a long-lived one
$accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken);
}
$fb->setDefaultAccessToken($accessToken);
$response = $fb->get('/me?fields=id,name,email');
$plainOldArray = $response->getDecodedBody();
//if user exist sign them in otherwise sign them up
$query = ParseUser::query();
$query->equalTo("username", 'FB:' . $plainOldArray['id']);
$results = $query->find();
if (count($results) === 1) {
$user = ParseUser::logIn('FB:' . $plainOldArray['id'], config('facebook.upwd'));
$user->set('social', "facebook:" . $accessToken);
return $this->determineRoute($request);
} else {
$user = new ParseUser();
$user->set("username", 'FB:' . $plainOldArray['id']);
$user->set("password", config('facebook.upwd'));
$user->set("email", "FB_" . $plainOldArray['email']);
$user->set("name", $plainOldArray['name']);
$user->set("realEmail", $plainOldArray['email']);
$user->set("social", "facebook:" . $accessToken);
try {
$user->signUp();
return $this->determineRoute($request);
} catch (ParseException $ex) {
var_dump("Save Error");
// Show the error message somewhere and let the user try again.
echo "Error: " . $ex->getCode() . " " . $ex->getMessage();
var_dump($plainOldArray['email']);
var_dump($accessToken);
die;
}
}
} catch (FacebookRequestException $ex) {
// When Facebook returns an error
echo "Error: " . $ex->getCode() . " " . $ex->getMessage();
die;
} catch (\Exception $ex) {
// When validation fails or other local issues
//var_dump($plainOldArray['email']);
//var_dump($accessToken);
echo "Error: " . $ex->getCode() . " " . $ex->getMessage();
die;
}
if (!empty($accessToken)) {
// Logged in.
//$access_token = $helper->getAccessToken();
echo "LOGGED IN";
die;
} else {
if ($helper->getError()) {
header('HTTP/1.0 401 Unauthorized');
echo "Error: " . $helper->getError() . "\n";
echo "Error Code: " . $helper->getErrorCode() . "\n";
echo "Error Reason: " . $helper->getErrorReason() . "\n";
echo "Error Description: " . $helper->getErrorDescription() . "\n";
exit;
} else {
return redirect()->route('login');
}
}
}
示例9: setcookie
/* Redirect browser */
exit;
}
//Will remove any numbers, thus if it is all numbers the length will be 0
if (preg_match('/[a-zA-Z]/', $pass) == 0) {
setcookie("regError", "Password must contain letters");
header("Location: index.php");
/* Redirect browser */
exit;
}
/* set session storage */
ParseClient::setStorage(new ParseSessionStorage());
try {
$user->setUsername($_POST["username"]);
$user->setEmail($_POST["username"]);
$user->setPassword($_POST["password"]);
$user->set("friendlyName", $_POST["friendly"]);
$user->set("isAdmin", TRUE);
$user->signUp();
$_SESSION["username"] = ParseUser::getCurrentUser()->get("username");
$_SESSION["friendlyName"] = ParseUser::getCurrentUser()->get("friendlyName");
} catch (ParseException $ex) {
// error in $ex->getMessage();
setcookie("regError", $ex->getMessage());
}
} else {
setcookie("regError", "Username, Password, and Chat Name are required");
}
header("Location: index.php");
/* Redirect browser */
exit;
示例10: postVal
include "include/parse.php";
use Parse\ParseUser;
use Parse\ParseException;
use Parse\ParseGeoPoint;
$status = "";
function postVal($name)
{
if (!empty($_POST[$name])) {
return $_POST[$name];
}
return null;
}
if (!empty($_POST['email']) && !empty($_POST['password']) && !empty($_POST['fullname']) && !empty($_POST['phone']) && !empty($_POST['address'])) {
$user = new ParseUser();
$user->set("username", $_POST['email']);
$user->set("password", $_POST['password']);
$user->set("email", $_POST['email']);
$user->set("phone", $_POST['phone']);
$user->set("fullName", $_POST['fullname']);
$user->set("address", $_POST['address']);
$user->set("role", "user");
$user->set("approve", 0);
$ne = new ParseGeoPoint($_POST['NorthEastLat'], $_POST['NorthEastLng']);
$sw = new ParseGeoPoint($_POST['SouthWestLat'], $_POST['SouthWestLng']);
$location = [$ne, $sw];
$user->setArray("location", $location);
try {
$user->signUp();
header('Location: afterRegister.html');
} catch (ParseException $ex) {
示例11: signUpUser
function signUpUser($email, $password, $token, $phone = "301-828-8684")
{
$user = new ParseUser();
$user->set("username", $email);
$user->set("password", $password);
$user->set("email", $email);
$user->set("phone", $phone);
// Parse try-catch
try {
$user->signUp();
// Stripe try-catch
try {
$customer = \Stripe\Customer::create(array('email' => $email, 'card' => $token));
$user->set("stripeID", $customer->id);
$user->save();
} catch (\Stripe\Error\InvalidRequest $e) {
$user->destroy();
return $e->getMessage();
} catch (\Stripe\Error\Authentication $e) {
$user->destroy();
return $e->getMessage();
} catch (\Stripe\Error\ApiConnection $e) {
$user->destroy();
return $e->getMessage();
} catch (\Stripe\Error\Base $e) {
$user->destroy();
return $e->getMessage();
} catch (Exception $e) {
$user->destroy();
return $e->getMessage();
}
} catch (\Parse\ParseException $ex) {
return $ex->getMessage();
}
return "success";
}
示例12: registration
public function registration($obj)
{
$conn = new Connect();
$var = $conn->connect_to_db();
$user = new ParseUser();
$user->set("username", $obj["email"]);
$user->set("password", $obj["nombre"]);
$user->set("Nombre", $obj["nombre"]);
$user->set("Apellido", $obj["apellido"]);
$turno = new ParseObject("Turnos", "vZFV0A9SH0", true);
$user->set("Turno_FK", $turno);
//comprobación del tipo de usuario ingresado
if ($obj["tipo"] == "alumno") {
$usuario = new ParseObject("Tipo_de_Usuario", "UgTuNHEQEZ", true);
$user->set("TipoUsuario", $usuario);
} else {
if ($obj["tipo"] == "mentor") {
$usuario = new ParseObject("Tipo_de_Usuario", "FLAdvaR13B", true);
$user->set("TipoUsuario", $usuario);
} else {
echo "Tipo de usuario ingresado no válido";
}
}
//comprobación de la sede asignada
if ($obj["sede"] == "palermo") {
$sede = new ParseObject("Sedes", "JNMeQHySaD", true);
$user->set("NombreSede_FK", $sede);
} else {
if ($obj["sede"] == "baldomero") {
$sede = new ParseObject("Sedes", "7nXbEOqT20", true);
$user->set("NombreSede_FK", $sede);
} else {
if ($obj["sede"] == "cortazar") {
$sede = new ParseObject("Sedes", "xuasyHhTez", true);
$user->set("NombreSede_FK", $sede);
} else {
if ($obj["sede"] == "usuaria") {
$sede = new ParseObject("Sedes", "SPWDWNpNFX", true);
$user->set("NombreSede_FK", $sede);
} else {
if ($obj["sede"] == "cmd") {
$sede = new ParseObject("Sedes", "0CQXZyBeai", true);
$user->set("NombreSede_FK", $sede);
} else {
if ($obj["sede"] == "accenture") {
$sede = new ParseObject("Sedes", "laLuPbJAYT", true);
$user->set("NombreSede_FK", $sede);
} else {
if ($obj["sede"] == "boca") {
$sede = new ParseObject("Sedes", "aFhJvV7lHz", true);
$user->set("NombreSede_FK", $sede);
} else {
echo "Sede ingresada no válida";
}
}
}
}
}
}
}
try {
$user->signUp();
echo "Guardado exitoso";
} catch (ParseException $ex) {
// Show the error message somewhere and let the user try again.
echo "Error: " . $ex->getCode() . " " . $ex->getMessage();
}
}
示例13: userSignUp
public function userSignUp($params)
{
// creat new ParseUser object
$user = new ParseUser();
// set params
foreach ($params as $name => $data) {
switch ($data['type']) {
case 'array':
$user->setArray($name, $data['value']);
break;
default:
$user->set($name, $data['value']);
break;
}
}
try {
$user->signUp();
return array('status' => '1', 'data' => $user);
} catch (ParseException $e) {
return array('status' => '0', 'data' => $e->getMessage());
}
}
示例14: ParseSessionStorage
<?php
require_once '../includes/Twig/Autoloader.php';
require_once "../config.php";
use Parse\ParseClient;
use Parse\ParseSessionStorage;
use Parse\ParseUser;
ParseClient::setStorage(new ParseSessionStorage());
$user = new ParseUser();
$user->set("username", $_POST['username']);
$user->set("password", $_POST['password']);
$user->set("email", $_POST['email']);
try {
$user->signUp();
echo 1;
// Hooray! Let them use the app now.
} catch (ParseException $ex) {
// Show the error message somewhere and let the user try again.
echo 0;
}
示例15: uniqid
use Parse\ParseException;
use Parse\ParseUser;
use Parse\ParseSessionStorage;
use Parse\ParseClient;
use Parse\ParseQuery;
use Parse\ParseObject;
$func = $_POST['check'];
if ($func == 'register') {
echo user_register($_POST['username'], $_POST['first'], $_POST['last'], $_POST['password'], $_POST['email'], $_POST['location'], $_POST['lat'], $_POST['lng']);
mail_box($_POST['email'], 'Register', 'Thank you for registering', 'register');
}
if ($func == 'guest') {
(string) ($uniq = uniqid());
$name = "Guest-" . $uniq;
$user = new ParseUser();
$user->set("username", $name);
$user->set("password", $uniq);
$user->setArray("connected", []);
$user->set("status", 0);
$user->set("avatar", "img/profile_default_male.jpg");
$response = new Response();
try {
$user->signUp();
//user_register_create_chat($user);
$_SESSION['user'] = $user;
$_SESSION['notification'] = true;
$query = new ParseQuery("_Session");
$query->equalTo("user", $user);
$query->includeKey("user");
$query->descending("createdAt");
$query->limit(1);