How to create users with custom field in Appcelerator API using PHP CURL?

If you want to creates a new user with custom field then it's not a big deal. Follows the instructions and use the code below.

Instructions: When creating a user, you must specify either:
    * username
    * email address, first name, and last name

A user can have both an email address and username specified. However, if username is blank then email address, first name and last name are required.

We are creating here a user just by using the username, we are not using email here. So we just need username, password and password_confirmation.

Role: Whatever you want to add. I am taking as 'teacher'. It is not mendatory.
Custom Field: 'pranay' having value equal to '23'. It can be anything. Ex: Age, Gender.

PHP CURL Code: 
$key = 'YourAppceleratorKey';
$Curl_Session = curl_init("https://api.cloud.appcelerator.com/v1/users/create.json?key=" . $key.'&pretty_json=true&role=teacher&custom_fields={"pranay":23}');
 
curl_setopt($Curl_Session, CURLOPT_RETURNTRANSFER, true);    
$post_array = array('username' => "pgtest3", 'password' => "pgtest3" , 'password_confirmation' => "pgtest3");
curl_setopt($Curl_Session, CURLOPT_POSTFIELDS, $post_array);
$resp = curl_exec($Curl_Session);
curl_close($Curl_Session);

Reference Document: http://docs.appcelerator.com/cloud/latest/#!/api/Users-method-create
How to create users with custom field in Appcelerator API using PHP CURL? How to create users with custom field in Appcelerator API using PHP CURL? Reviewed by Web Technology Funda on 2:53:00 AM Rating: 5

No comments

Free! Free!Free! Subscribe to Get Free PHP (Magento) tutorial Update in Your Inbox!!! Hurry Up!!!