Creating App User

Creating a User with App42 platform for your app is pretty straightforward. You have to just put a few lines of code in your app and you are done. Minimum parameter requirements for user creation are username, password and email. The following snippet will create a user in the App42 Cloud.

If you want to create a user with the extended profile option, you are free to do so. Both scenarios are explained below.

1. Creating a User With Default Parameters

Following is the snippet to create a user with default parameters username, password and email id.

  • create User Api for Android
  • create User Api for J2ME
  • create User Api for Android
  • create User Api for iOS
  • create User Api for Java
  • create User Api for .NET
  • create User Api for Unity
  • create User Api for Ruby
  • create User Api for Rest
  •  create User Api for WP7/WP8
  • create User Api for Flash
String userName = "Nick";  
String pwd = "********";  
String emailId = "nick@shephertz.com";  
/* This will create user in App42 cloud and will return created User 
object in onSuccess callback method */                           
userService.createUser(userName, pwd, emailId, new App42CallBack() {
public void onSuccess(Object response) 
{
	User user = (User)response;
	System.out.println("userName is " + user.getUserName());
	System.out.println("emailId is " + user.getEmail());
}
public void onException(Exception ex) 
{
	System.out.println("Exception Message"+ex.getMessage());
}
});   
NSString *userName = @"Nick";  
NSString *pwd = @"********";  
NSString *emailId = @"nick@shephertz.com";       
User *user = [userService createUser:userName password:pwd emailAddress:emailId]; 
/* This will create user in App42 cloud and will return User object */
NSLog(@"userName is %@" , user.userName);  
NSLog(@"emailId is %@" ,  user.emailId);  
String userName = "Nick";   
String pwd  = "*****";
String emailId = "nick@shephertz.com";
userService.CreateUser(userName,pwd,emailId, this);  
/* This will create user in App42 cloud and will return User object */  
	  void App42Callback.OnSuccess(Object response)  
	  {  
		 User user = (User) response;     
		 Console.WriteLine("userName is " + user.GetUserName());  
		 Console.WriteLine("emailId is " + user.GetEmail());  
	  }  
 
String userName = "Nick";  
String pwd = "********";  
String emailId = "nick@shephertz.com";  
User user = userService.createUser(userName, pwd, emailId); 
/* This will create user in App42 cloud and will return User object */ 
System.out.println("userName is " + user.getUserName());  
System.out.println("emailId is " + user.getEmail());  
var userName = "Nick";  
var pwd = "*********";  
var emailId = "nick@shephertz.com";  
var result ;  
userService.createUser(userName, pwd, emailId,{  
	success: function(object) {  
		var userObj = JSON.parse(object);  
		result = userObj.app42.response.users.user;
		console.log("userName is " + result.userName)
		console.log("emailId is " + result.email)
	},  
	error: function(error) {  
	}  
}); 
String userName = "Nick";  
String pwd = "********";  
String emailId = "nick@shephertz.com";                           
User user = userService.createUser(userName, pwd, emailId); 
/* This will create user in App42 cloud and will return User object */  
System.out.println("userName is " + user.getUserName());  
System.out.println("emailId is " + user.getEmail());  
String userName = "Nick";
String pwd = "********";
String emailId = "nick@shephertz.com";   
userService.CreateUser(userName, pwd, emailId,new UnityCallBack()); 
public class UnityCallBack : App42CallBack
{
	public void OnSuccess(object response)
	{
		User user = (User) response;
		/* This will create user in App42 cloud and will return User object */  
		App42Log.Console("userName is " + user.GetUserName());
		App42Log.Console("emailId is " + user.GetEmail()); 
	}
	public void OnException(Exception e)
	{
		App42Log.Console("Exception : " + e);
	}
}
String userName = "Nick";
String pwd = "********";
String emailId = "nick@shephertz.com";
User user = userService.CreateUser(userName, pwd, emailId); 
/* This will create user in App42 cloud and will return User object */ 
Console.WriteLine("userName is " + user.GetUserName());
Console.WriteLine("emailId is " + user.GetEmail());
$userName = "Nick";  
$pwd = "********";  
$emailId = "nick@shephertz.com";                             
$user = $userService->createUser($userName, $pwd, $emailId); 
/* This will create user in App42 cloud and will return User object */  
print_r("userName is " . $user->getUserName());  
print_r("emailId is " . $user->getEmail());  
uName = "Nick";  
pwd = "********";  
emailId = "nick@shephertz.com";                            
user = userService.create_user(uName, pwd, emailId); 
/* This will create user in App42 cloud and will return User object */  
puts "userName is #{user.userName}";  
puts "email is #{user.email}";   
var userName:String = "Nick";   
var pwd:String  = "*****";
var emailId:String = "nick@shephertz.co.in";
userService.createUser(userName,pwd,emailId, new callback());  
public class callback implements App42CallBack  
{  
	public function onException(excption:App42Exception):void  
	{  
		trace("Exception Message");  
	}  
	public function onSuccess(response:Object):void  
	{  
		var user:User = User(response);
		trace("response is : " + user);
	}  
}
The request format for create User is  
URL : https://api.shephertz.com/cloud/1.0/user  
Method : POST  
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>  
Accept : application/json  
Content-Type : application/json  
Body :  
{  
	"app42": {  
		"user": {  
			"userName": "Nick",  
			"password": "********",  
			"email": "nick@shephertz.com"  
		}  
	}  
}  

2. Creating a User With Extended Parameters

If your app demands more parameters for your user you can create a user profile with extended parameters. This method can be called once the user is created with default parameters as explained above.

  • create User Api for Android
  • create User Api for J2ME
  • create User Api for Android
  • create User Api for iOS
  • create User Api for Java
  • create User Api for .NET
  • create User Api for Unity
  • create User Api for Ruby
  • create User Api for Rest
  •  create User Api for WP7/WP8
  • create User Api for Flash
String userName = "Nick"	
User userObj = new User();
userObj.setUserName(userName);
Profile profile = userObj.new Profile();
Date date = new Date(); /* returns the current date object.User can set any date */ 
profile.setFirstName("Nick");
profile.setLastName("Gill");
profile.setSex(UserGender.MALE);
profile.setDateOfBirth(date);
profile.setCity("Houston");
profile.setState("Texas");
profile.setPincode("74193");
profile.setCountry("USA");
profile.setMobile("+1-1111-111-111");
profile.setHomeLandLine("+1-2222-222-222");
profile.setOfficeLandLine("+1-3333-333-333");
/* Following will create user profile and returns User object 
which has profile object inside in onSuccess callback method */
userService.createOrUpdateProfile(userObj, new App42CallBack() {
public void onSuccess(Object response) 
{
	User user = (User)response;
	System.out.println("userName is " + user.getUserName());
	System.out.println("firstName is " + user.getProfile().getFirstName()); 
	System.out.println("city is " + user.getProfile().getCity()); 
	System.out.println("country is " + user.getProfile().getCountry()); 
}
public void onException(Exception ex) 
{
	System.out.println("Exception Message"+ex.getMessage());
}
}); 
NSString *userName = @"Nick";						
User *userObj = [[User alloc]init];
userObj.userName = userName;
Profile *profile = [[Profile alloc]initWithUser:userObj];			
profile.firstName = @"Nick";
profile.lastName = @"Gill";
profile.sex = MALE;
NSDate *date = [NSDate date]; 	/* returns the current date object.User can set any date */ 		
profile.dateOfBirth = date;
profile.city = @"Houston";
profile.state = @"Texas";
profile.pincode = @"74193";
profile.country = @"USA";
profile.mobile = @"+1-1111-111-111";
profile.homeLandLine = @"+1-2222-222-222";
profile.officeLandLine = @"+1-3333-333-333";			
User *user = [userService createOrUpdateProfile:userObj] 
/* Above line will create user profile and returns User object which has profile object in it. */
NSLog(@"firstName is %@" ,  user.profile.firstName);
String userName = "Nick";   
User user =  new User();
user.SetUserName(userName);
User.Profile profile = new User.Profile(user);
profile.SetCountry("USA");
profile.SetCity("Houston");
profile.SetDateOfBirth(new DateTime());
profile.SetFirstName("Nick");
profile.SetLastName("Gill");
profile.SetHomeLandLine("+1-1800-877-453");
profile.SetOfficeLandLine("+1-1800-111-999");
profile.SetMobile("+958901234571");
profile.SetSex(UserGender.MALE); 
userService.CreateOrUpdateProfile(user, new Callback());
/* Above line will create user profile and returns User object which has profile object in it. */
public class Callback : App42Callback  
{  
	public void OnSuccess(Object response)  
	{
		User user = (User) response;  
		String jsonResponse = user.ToString();    
	} 
	public void OnException(App42Exception exception)  
	{  
	Console.WriteLine("Exception Message : " + exception);  
	}  	
}      
String userName = "Nick";						
User userObj = new User();
userObj.setUserName(userName);
//You can also get User Object from getUser Method call
Profile profile = userObj.new Profile();
profile.setFirstName("Nick");
profile.setLastName("Gill");
profile.setSex(UserGender.MALE);
Date date = new Date(); /* returns the current date object.User can set any date */ 
profile.setDateOfBirth(date);
profile.setCity("Houston");
profile.setState("Texas");
profile.setPincode("74193");
profile.setCountry("USA");
profile.setMobile("+958901234571");
profile.setHomeLandLine("+1-1800-877-453");
profile.setOfficeLandLine("+1-1800-111-999");
User user = userService.createOrUpdateProfile(userObj); 
/* Above line will create user profile and returns User object which has profile object in it. */
System.out.println("firstName is " + user.getProfile().getFirstName());                     
var userName  = "Nick",
result ;
userService.setFirstName("Nick");
userService.setLastName("Gill");
userService.setOfficeLandLine("+1-1800-111-999");
userService.setCountry("USA");
userService.setCity("Houston");
userService.setMobile("+958901234571");
userService.createOrUpdateProfile(userName,{
success: function(object) 
{  
	var userObj = JSON.parse(object);  
	result = userObj.app42.response.users.user;
	console.log("userName is : " + result.userName)
	var profile = result.profile;
	console.log("firstName is : " + profile.firstName);
	console.log("lastName is : " + profile.lastName);
	
},  
error: function(error) {  
	}  
});
String userName = "Nick";						
String pwd = "********";
String emailId = "nick@shephertz.com";					
User userObj = new User();
userObj.setUserName(userName);
Profile profile = userObj.new Profile();
Date date = new Date(); /* returns the current date object.User can set any date */ 
profile.setFirstName("Nick");
profile.setLastName("Gill");
profile.setSex(UserGender.MALE);
profile.setDateOfBirth(date);
profile.setCity("Houston");
profile.setState("Texas");
profile.setPincode("74193");
profile.setCountry("USA");
profile.setMobile("+1-1111-111-111");
profile.setHomeLandLine("+1-2222-222-222");
profile.setOfficeLandLine("+1-33333-333-333");
User user = userService.createOrUpdateProfile(userObj); 
/* Above line will create user profile and returns User object which has profile object in it. */
System.out.println("firstName is " + user.getProfile().getFirstName());  
String userName = "Nick";   
User user = new User();
user.SetUserName(userName);
User.Profile profile = new User.Profile(user);
profile.SetCountry("USA");
profile.SetCity("Houston");
profile.SetDateOfBirth(new DateTime());
profile.SetFirstName("Nick");
profile.SetLastName("Gill");
profile.SetHomeLandLine("+1-1800-877-453");
profile.SetOfficeLandLine("+1-1800-111-999");
profile.SetMobile("+958901234571");
profile.SetSex(UserGender.MALE); 
flag = false;
userService.CreateOrUpdateProfile(user, new UnityCallBack());
public class UnityCallBack : App42CallBack
{
	public void OnSuccess(object response)
	{
		User user = (User) response;
		App42Log.Console("userName is " + user.GetUserName());
		App42Log.Console("emailId is " + user.GetEmail()); 
	}
	public void OnException(Exception e)
	{
		App42Log.Console("Exception : " + e);
	}
String userName = "Nick";						
User userObj =  new User();
user.SetUserName(userName);
User.Profile profile = new User.Profile(userObj);
profile.SetFirstName("Nick");
profile.SetLastName("Gill");
profile.SetSex(UserGender.MALE);
profile.SetDateOfBirth(DateTime.Now);
profile.SetCity("Houston");
profile.SetState("Texas");
profile.SetPincode("74193");
profile.SetCountry("USA");
profile.SetMobile("+1-1111-111-111");
profile.SetHomeLandLine("+1-2222-222-222");
profile.SetOfficeLandLine("+1-3333-333-333");
User user = userService.CreateOrUpdateProfile(userObj); 
/* Above line will create user profile and returns User object which has profile object in it. */
User.Profile profileObj = user.GetProfile();
Console.WriteLine("firstName is " + profile.GetFirstName());
$userName = "Nick";						
$userObj = new User();
$userObj.setUserName($userName);
$profile = new Profile($userObj);
$date = date(DATE_ATOM, mktime());
$date1 = strtotime($date);
$currentDate= date('Y-m-j', $date1);/* returns the current date object.User can set any date */ 
$profile->setCountry("USA");
$profile->setCity("Houston");
$profile->setCountry("India");
$profile->setDateOfBirth("14-02-2012");
$profile->setFirstName("Nick");
$profile->setLastName("Gill");
$profile->setHomeLandLine("+1-1800-877-453");
$profile->setOfficeLandLine("+1-1800-111-999");
$profile->setMobile("958901234571");
$profile->setSex(UserGender::MALE);
$profile->setState("Texas");
$user = $userService->createOrUpdateProfile($userObj); 
/* Above line will create user profile and returns User object which has profile object in it. */
$profile = $user->getProfile();   
print_r("firstName is" . $profile->getFirstName();  
userName = "Nick";
email = "nick@shephertz.com";
user = App42::User::User.new(); 
user.userName = userName;
profileObj = App42::User::User::Profile.new();
/* This will create a user in App42 cloud and will return User object */ 
profileObj.officeLandLine = ("+1-1800-111-999");
profileObj.firstName = "Nick";
profileObj.dateOfBirth = "03-11-2012";
profileObj.country = ("USA");
profileObj.city = ("Houston");
profileObj.lastName = ("Gill");
profileObj.mobile = ("+958901234571");
profileObj.pincode = ("74193");
profileObj.sex = App42::User::User::UserGender.new.enum("MALE");
profileObj.homeLandLine = ("+1-1800-877-453");
profileObj.state = ("Texas");
user.profile= profileObj;
userObj = userService.createOrUpdateProfile(user);
/* The above lines create a user profile and returns User object which has the profile object in it. */
puts "firstName #{userObj.profile.firstName}";
Coming Soon
The request format for createOrUpdateProfile is
URL : https://api.shephertz.com/cloud/1.0/user/profile
Method : PUT
QueryParam : apiKey=<apiKey>&signature=<signature>&version=<version>&timestamp=<UTC_FORMATED_TIME_STAMP>
Accept : application/json
Content-Type : application/json
Body :
{
	"app42": {
		"user": {
			"userName": "Nick",
			"profileData": {
						"firstName": "Nick ",
						"lastName": "Gill",
						"sex": "Male",
						"dateOfBirth": "2012-12-11T18:30:00.000Z",
						"city": "Houston",
						"state": "Texas",
						"pincode": "74193",
						"country": "USA",
						"mobile": "+1-1111-111-111",  
						"homeLandLine": "+1-2222-222-222",  
						"officeLandLine": "+1-33333-333-333",
			}
		}
	}
}

3. What If I Already Have a Userbase?

App42 platform does not mandate you to create a user base with us. If your userbase is somewhere else (Facebook/Twitter/Enterprise etc.) you can still use our APIs. All our APIs can be used in isolation without any dependency on other APIs. For example if your user is already a Facebook user, you can use the Facebook userid as a username in our APIs and can make your app. We don’t force to have userbase with us.

More Details?

bullet Go To User API Usage Guide