Optionally the user can be activated immediately. If the email parameter contains a string, an email template named by that string will used to send out an activation or welcome email.
The return value is the newly created user id.
This method can only be called with a valid developer key.
Required fields for userData are user and email.
Optional fields are firstname, lastname, password, address1, address2, city, state, country, postal, gender (M or F), birthdate, cellphone, phone, website, occupation, school, language, geo_latitude, geo_longitude and newsletter.
The "user" field must only contain letters (a-z), digits (0-9), underscore (_), hyphen (-), period (.), and the "at" sign (@).
There's also an optional meta field in the userData array. This field can contain any data array.
An array with user information. Only user and email are required, other possible key / value pairs are listed below.
activate
bool
Optional
false
Automatically activate user. This may be either true or false. When true the user is activated upon registration.
sendEmail
mixed
Optional
false
Whether or not to send an e-mail to activate the user that is used in the registration call. When true an e-mail is sent to the e-mail address provided in the array.
Array key / value pairs
The possible key value pairs that you can use in your userData array.
Name
Type
Required
Default Value
Description
user
STRING
Required
none
Username for the account. The user parameter must only contain letters (a-z or A-Z), digits (0-9), underscore (_), hyphen (-), period (.), and the "at" sign (@).
email
STRING
Required
none
Email address for the account holder. This has to be a properly formatted email address.
firstname
STRING
Optional
none
Firstname for the account holder
lastname
STRING
Optional
none
Lastname for the account holder
password
STRING
Optional
random string
Password for the account holder (if none is provided the system will generate one and send it to the user)
address1
STRING
Optional
none
The account holders address.
address2
STRING
Optional
none
A second line for the account holders address.
city
STRING
Optional
none
The account holders city.
language
STRING
Optional
none
The language the account holder is using poss.
state
STRING
Optional
none
The account holders state/province.
country
STRING
Optional
none
The account holders country.
postalcode
STRING
Optional
none
The account holders zip or postal code.
birthdate
STRING
Optional
none
The account holders birth date.
cellphone
STRING
Optional
none
The account holders cell phone.
phone
STRING
Optional
none
The account holders phone number.
website
STRING
Optional
none
The account holders website.
accounttype
STRING
Optional
0
The account type for the account holder.
occupation
STRING
Optional
none
The account holders occupation.
newsletter
BOOLEAN
Optional
0
Whether the account holder wants to receive a newsletter.
profile_complete
BOOLEAN
Optional
0
If a users profile should be marked as complete or not.
gender
CHAR
Not required
none
The account holders gender, acceptable values are M or F.
meta
STRING
Optional
none
Any meta data you wish to store about the account holder.
external_id
STRING
Optional
none
The id provided by a 3rd party external authorization system. NB: This is to be used with 'external_id_provider'.
external_id_provider
INTEGER
Optional
none
The integer that represents the 3rd party that provided the external id. Possible values are:
1 (Facebook)
4 (Janrain)
5 (Gigya)
6 (Stripe)
NOTE: The external_id_provider is required if external_id is passed.
$path = 'http://api.crowdspark.com/services/php';
// Listing the arguments
$arguments = array(
'APIKEY' => '',
'method' => 'users.register',
'vhost' => '2',
'userData' => $userData,
'activate' => $activate,
'sendEmail' => $sendEmail
);
// http_build_query basically turns an array into a url-encoded list of variables
$url = $path .'?' . http_build_query($arguments,null,'&');
// get the contents from the specified url
$data = file_get_contents($url);
// transform it back into php data structures
$data = unserialize($data);
// the actual data is stored in $data['result']
print_r($data['result']);
// Include the client
require_once 'XML/RPC.php';
// Create the XMLRPC Client
$client = new XML_RPC_Client('/services/xmlrpc?APIKEY=', 'api.crowdspark.com');
// PEAR's XML-RPC client requires all arguments to wrapped in a special value class
// XML_RPC_encode converts this automatically
$arguments = array(
XML_RPC_encode('2'),
XML_RPC_encode($userData),
XML_RPC_encode($activate),
XML_RPC_encode($sendEmail)
);
// Creating an XML-RPC message
$message = new XML_RPC_Message('users.register',$arguments);
// Sending the message to the server
$response = $client->send($message);
// We also need to decode the response back to normal PHP types
$response = XML_RPC_decode($response);
print_r($response);
/*
* In ActionScript 2 remote service calls are done using the RemotingConnector Component.
* An instance of the component must exist on the stage and have an instance name.
*
* Results and Faults are handled by addEventListener's and the call parameters are placed inside of an associative array
*
* You must also specify the service class and method names under the appropriate property fields of the component
*/
var gatewayURL:String = "/services/amf2";
//Set up service call
myRemConn_rc.gatewayUrl = gatewayURL;
myRemConn_rc.serviceName = "users";
myRemConn_rc.methodName = "register";
myRemConn_rc.params = {2:vhost, userData:userData, activate:activate, sendEmail:sendEmail};
myRemConn_rc.addEventListener("result", widgetResult);
myRemConn_rc.addEventListener("status", widgetFault);
//Make the call
myRemConn_rc.trigger();
/*
* Handles service result.
*/
function widgetResult(ev:Object){
//Do stuff
//Data is returned inside of ev.target.results
//(i.e. ev.traget.results.description or ev.traget.results.settings.color)
}
/*
* Handles service fault.
*/
function widgetFault(ev:Object){
//Display Error
trace("Categories Error - " + ev.code + " - " + ev.data.faultstring);
}
/*
* In ActionScript 3 remote service calls are done using the NetConnection Object.
* A Responder Object controls what functions handle successful or failed calls
* and any parameters for the call are placed in an array and passed as a parameter
* in the NetConnection.call() method.
*/
var gatewayURL:String = "/services/amf2";
var parameters:Array = new Array(vhost, userData, activate, sendEmail);
var connection:NetConnection = new NetConnection();
connection.connect(gatewayURL);
connection.call("users.register", new Responder(widgetResult, widgetFault), parameters);
/*
* Handles service result.
*/
function widgetResult(ev:Object):void{
//Do stuff
//Data is returned inside of ev
//(i.e. ev.description or ev.settings.color)
}
/*
* Handles service fault.
*/
function widgetFault(ev:Object):void{
//Display Error
error.showError(parentClip, ev.code + " - " + ev.description, "Please refresh your browser to try again.");
error.x = (parentClip.width - error.width) / 2;
error.y = (parentClip.height - error.height) / 2;
}
<%@ Page Language="vb" %>
<%
' REST gateway
dim gateway as string = "http://api.filemobile.com/services/rest/"
' Service + method we're calling.
dim method as string = "users/register"
dim apiKey as string = ""
dim url as string = gateway & method & "?APIKEY=" & apiKey & "&vhost=2" & "&userData=" & userData
' HTTP Client
dim wcHTTPScrape as new System.net.WebClient()
' Opening a stream
dim objInput as System.IO.Stream = wcHTTPScrape.OpenRead(url)
dim objReader as new System.IO.StreamReader ( objInput )
' Reading the entire HTTP response and output it
Response.Write ( objReader.ReadToEnd () )
objReader.Close ()
objInput.Close ()
%>