Updates a user's information personal information and metadata.
The meta data field is a bit special. The meta field must be supplied as an array. The new user meta-data will be a merge of the existing meta-date + the newly supplied metadata. Only the top-level elements in the array will be merged, if you have an array within an array, the old top-level array will be completely overwritten. If you just want to get rid of some metadata, we advice to simply supply an empty value.
If no user id is supplied this method will update the information of the currently logged in user.
These are the fields that can be updated using the updateUserInfo call. To update these fields, the arguments have to be passed as an array in the newProperties parameter.
Name | Type | Description |
---|
firstname | STRING | The users first name. |
lastname | STRING | The users last name. |
email | STRING | The users e-mail address. |
user | STRING | The users user name. |
password | STRING | The users password. |
city | STRING | The users city. |
country | STRING | The users country. |
postalcode | STRING | The users postal code. |
newsletter | BOOLEAN | Whether or not the user wants the newsletter, 0 is false, 1 is true. |
gender | CHAR | The sex of the user, M is male and F is female. |
birthday | DATE | The users date of birth. |
language | STRING | The users language |
state | STRING | The users state. |
website | STRING | The users website. |
occupation | STRING | The users occupation. |
phone | STRING | The user telephone number. |
cellphone | STRING | The users cell phone number. |
address1 | STRING | The first line of the users address. |
address2 | STRING | The second line of the users address. |
nickname | STRING | The users nickname. |
external_id | STRING | The id provided by a 3rd party external authorization system. NOTE: If this is set to blank, the user's external id will be deleted. |
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)
- 7 (Google)
- 8 (Apple)
- 9 (Twitter)
- 10 (Instagram)
- 11 (YouTube)
NOTE: The external_id_provider is required if external_id is passed. |
external_id_provider_url | STRING | The URL of the 3rd party that provides the external id. |
external_avatar_url | STRING | The URL of the avatar from the 3rd party that provided the external id. |
external_id_sub_provider | STRING | The sub-provider of the Janrain external id. Currently, the external id sub-providers are: NOTE: The external_id_sub_provider is required if Janrain is set as the external_id_provider. |
description | STRING | The users description. |
meta | ARRAY | Any meta data that you may want to save. |
deviceInfo | ARRAY | Array of mobile device information. An example:
$deviceInfo[0] = Array ( 'latitude' => '43.648311', 'longitude' => '-79.396021', 'lastupdatetime' => '2012-12-10 18:32:21', 'commentnotification' => 1, 'appcode' => 'MOB123', 'assignmentnotification' => 1, 'settings' => 'a:1:{s:22:"notificationBadgeCount";s:1:"0";}'
$deviceInfo[1] = Array ( 'latitude' => '44.648311', 'longitude' => '-78.396021', 'lastupdatetime' => '2012-12-11 18:32:21', 'commentnotification' => 0, 'assignmentnotification' => 1, 'deviceType'=> 'ios','appcode' => 'MOB123' ); |
created | DATETIME | The time that the user was created. |
no_comment_notifications | INT | The number of comments that user has made. |
disabled | BOOLEAN | Whether or not the user is disabled, 0 is false, 1 is true. |
overrideExistingMeta | BOOLEAN | If set to TRUE, the existing meta data will be overwritten, otherwise the existing meta data will be merged with the new meta data |
avatar | INT | The media id to be shown as the user's avatar. |
disable_media_notifications | INT | Set to 1 to disable the user's media notifications. Set to 0 to allow them. |
disable_thread_notifications | INT | Set to 1 to disable the user's thread notifications. Set to 0 to allow them. |
PHP-RPC
$path = 'https://api.newspark.ca/services/php';
// Listing the arguments
$arguments = array(
'APIKEY' => 'YOURAPIKEY',
'method' => 'users.updateUserInfo',
'id' => $id,
'newProperties' => $newProperties,
'returnUserInfo' => $returnUserInfo
);
// 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']);
back to topPEAR XMLRPC client
// Include the client
require_once 'XML/RPC.php';
// Create the XMLRPC Client
$client = new XML_RPC_Client('/services/xmlrpc?APIKEY={YOURAPIKEY}', 'api.newspark.ca');
// 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($id),
XML_RPC_encode($newProperties),
XML_RPC_encode($returnUserInfo)
);
// Creating an XML-RPC message
$message = new XML_RPC_Message('users.updateUserInfo',$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);
back to topSabreTooth XMLRPC client
// Include the client
require_once 'Sabre/XMLRPC/Client.php';
// Create the XMLRPC Client
$xmlrpc = new Sabre_XMLRPC_Client('https://api.newspark.ca/services/xmlrpc?APIKEY={YOURAPIKEY}');
$arguments = array(
$id,
$newProperties,
$returnUserInfo
);
$data = $xmlrpc->invoke('users.updateUserInfo',$arguments);
print_r($data);
back to topZend XMLRPC client
// Include the client
require_once 'Zend/XmlRpc/Client.php';
// Create the XMLRPC Client
$client = new Zend_XmlRpc_Client('https://api.newspark.ca/services/xmlrpc?APIKEY={YOURAPIKEY}');
$arguments = array(
$id,
$newProperties,
$returnUserInfo
);
$data = $client->call('users.updateUserInfo',$arguments);
print_r($data);
back to topActionscript 2
/*
* 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 = "updateUserInfo";
myRemConn_rc.params = {id:id, newProperties:newProperties, returnUserInfo:returnUserInfo};
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);
}
back to topActionscript 3
/*
* 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(id, newProperties, returnUserInfo);
var connection:NetConnection = new NetConnection();
connection.connect(gatewayURL);
connection.call("users.updateUserInfo", 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;
}
back to topREST service example
<%@ Page Language="vb" %>
<%
' REST gateway
dim gateway as string = "http://api.newspark.ca/services/rest/"
' Service + method we're calling.
dim method as string = "users/updateUserInfo"
dim apiKey as string = "YOURAPIKEY"
dim url as string = gateway & method & "?APIKEY=" & apiKey
' 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 ()
%>
back to topjQuery JSON
/*
* jQuery post example
*/
function updateUserInfo ( id, newProperties, returnUserInfo ) {
var params = {
"method" : 'users.updateUserInfo',
"id" : id,
"newProperties" : newProperties,
"returnUserInfo" : returnUserInfo}
$.post('/services/json',params
,function(response){
console.log(response);
});
back to topLocal API
// Get the Service Mapper
$mapper = Sabre_ServiceMap_Mapper::getMapper();
// Calling the method
$data = $mapper->users->updateUserInfo( $id, $newProperties, $returnUserInfo );
print_r($data);
back to top