Returns information about a specific user.
This method requires a username and a vhost ID.
Below you will find a list and description of all of the available fields to have returned with our users.getUserInfoByUserName service.
Name | Type | Description |
---|
id | INT | The user id for the requested user. |
user | STRING | The username for the requested user. |
password | STRING | An encrypted hash containing the user's password. |
email | STRING | The e-mail address for the requested user. |
firstname | STRING | The first name of the requested user. |
lastname | STRING | The last name for the requested user. |
city | STRING | The city for the requested user. |
gender | CHAR | The gender of the requested user. |
birthdate | DATE | The birthdate of the requested user. |
cellphone | STRING | The users cell phone number. |
phone | STRING | The users telephone number. |
website | STRING | The users website. |
occupation | STRING | The users occupation. |
address1 | STRING | The first line of the users address. |
address2 | STRING | The second line of the users address. |
postalcode | STRING | The postal code of the requested user. |
state | STRING | The state of the requested user. |
language | STRING | The requested users language. |
country | STRING | The requested users country. |
description | STRING | A description of the requested user. |
storage | INT | |
avatar | INT | An integer for the media item of the requested users avatar. |
created | DATETIME | The date and time that the user was created. |
lastlogin | DATETIME | The date and time that the user was last logged into the system. |
random1 | INT | A random number used for activating the account. |
random2 | INT | A random number used for activating the account. |
accounttype | INT | Not currently implemented. |
active | BOOLEAN | Whether or not the requested user is activated. |
disabled | BOOLEAN | Whether or not the requested user's account is disabled. |
newsletter | BOOLEAN | Whether or not the requested user has requested the newsletter. 0 is false, 1 is true. |
nickname | STRING | The requested users nickname. |
attempts | INT | The number of login attempts for the user since the last successful login. |
mobileblog | STRING | A url for a mobile blog for the requested user. |
publicfiles | INT | The number of media items that user has uploaded to the system. NOTE: You can find the value of notdeniedfiles by subtracting deniedfiles from publicfiles. |
unmoderatedfiles | INT | The number of media items the user has uploaded to the system that have yet to be moderated. |
approvedfiles | INT | The number of media items the user has uploaded to the system that have been approved. |
deniedfiles | INT | The number of media items uploaded by the user that have been denied. |
unmoderatedcomments | INT | The number of comments the user has posted that have yet to be moderated. |
approvedcomments | INT | The number of comments the user has posted that have been approved. NOTE: You can find the value of notdeniedcomments by calculating the sum of approvedcomments plus unmoderatedcomments. |
deniedcomments | INT | The number of comments the user has posted that have been denied. |
notdeniedcomments | INT | The number of comments the user has posted that have been approved or have yet to be mopderated. |
friends | INT | The number of users that have accepted this user's friend request. |
friends_notconfirmed | INT | The number of users that have yet to confirm this user's friend request. |
geo_latitude | FLOAT | The geographical latitude for the requested user. |
geo_longitude | FLOAT | The geographical longitude for the requested user. |
vhost | INT | The vhost for the requested user. |
meta | ARRAY | Any meta data that has been collected about the requested user. |
no_comment_notifications | INT | Set to 1 to prevent the user from receiving comment notifications. Set to 0 to allow the user to receive them. |
profile_complete | BOOLEAN | Whether or not the requested user has a complete profile. |
externalids | ARRAY | The user's external IDs, if any. |
gravatarid | STRING | An md5 hash of the user's email address, which is used to confirm the user's gravatar. |
Sample REST Response
http://api.newspark.ca/services/rest/users/getUserInfoByUserName?vhost=[VHOST_ID]&username=[USERNAME]&APIKEY=[APIKEY]
<?xml version="1.0" encoding="UTF-8"?>
<result>
<id>USER_ID</id>
<user>USER_NAME</user>
<password>HASHED_USER_PASSWORD</password>
<email>USER_EMAIL</email>
<firstname>USER_FIRSTNAME</firstname>
<lastname>USER_LASTNAME</lastname>
<city>USER_CITY</city>
<gender>M</gender>
<birthdate>2011-02-01</birthdate>
<cellphone>4162222222</cellphone>
<phone>4162222222</phone>
<website/>
<occupation/>
<address1>1 Toronto Road</address1>
<address2/>
<postalcode>M1M1M1</postalcode>
<state>ON</state>
<language/>
<country>CA</country>
<description/>
<storage>0</storage>
<avatar>0</avatar>
<created>2012-02-03 14:48:50</created>
<lastlogin>2012-02-03 16:30:11</lastlogin>
<random1>5045</random1>
<random2>151285996</random2>
<accounttype>0</accounttype>
<active>1</active>
<disabled>0</disabled>
<newsletter>0</newsletter>
<openidurl/>
<nickname/>
<attempts>0</attempts>
<mobileblog>0</mobileblog>
<publicfiles>0</publicfiles>
<unmoderatedfiles>0</unmoderatedfiles>
<approvedfiles>0</approvedfiles>
<deniedfiles>0</deniedfiles>
<friends>1</friends>
<friends_notconfirmed>0</friends_notconfirmed>
<geo_latitude>41.83209336689739</geo_latitude>
<geo_longitude>-84.44921875</geo_longitude>
<vhost>VHOST_ID</vhost>
<meta>
<lang>en</lang>
<twitterUserName/>
<rules>1</rules>
</meta>
<no_comment_notifications>0</no_comment_notifications>
<profile_complete>1</profile_complete>
<externalids/>
</result>
Sample JSON Response
{
"status": true,
"result": {
"id": USER_ID,
"user": "USER_NAME",
"password": "HASHED_USER_PASSWORD",
"email": "USER_EMAIL",
"firstname": "USER_FIRSTNAME",
"lastname": "USER_LASTNAME",
"city": "Toronto",
"gender": "M",
"birthdate": "2011-02-01",
"cellphone": "4162222222",
"phone": "4162222222",
"website": "",
"occupation": "",
"address1": "1 Toronto Road",
"address2": null,
"postalcode": "M1M1M1",
"state": "ON",
"language": "",
"country": "CA",
"description": "",
"storage": 0,
"avatar": 0,
"created": "2012-02-03 14:48:50",
"lastlogin": "2012-02-03 16:30:11",
"random1": 5045,
"random2": 151285996,
"accounttype": 0,
"active": "1",
"disabled": "0",
"newsletter": "0",
"openidurl": "",
"nickname": "",
"attempts": 0,
"mobileblog": 0,
"publicfiles": 0,
"unmoderatedfiles": 0,
"approvedfiles": 0,
"deniedfiles": 0,
"friends": 1,
"friends_notconfirmed": 0,
"geo_latitude": "41.83209336689739",
"geo_longitude": "-84.44921875",
"vhost": 231,
"meta": {
"lang": "en",
"twitterUserName": "",
"rules": "1"
},
"no_comment_notifications": 0,
"profile_complete": 1,
"externalids": []
}
}
PHP-RPC
$path = 'https://api.newspark.ca/services/php';
// Listing the arguments
$arguments = array(
'APIKEY' => 'YOURAPIKEY',
'method' => 'users.getUserInfoByUserName',
'username' => $username,
'vhost' => '2'
);
// 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($username),
XML_RPC_encode('2')
);
// Creating an XML-RPC message
$message = new XML_RPC_Message('users.getUserInfoByUserName',$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(
$username,
'2'
);
$data = $xmlrpc->invoke('users.getUserInfoByUserName',$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(
$username,
'2'
);
$data = $client->call('users.getUserInfoByUserName',$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 = "getUserInfoByUserName";
myRemConn_rc.params = {username:username, 2:vhost};
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(username, vhost);
var connection:NetConnection = new NetConnection();
connection.connect(gatewayURL);
connection.call("users.getUserInfoByUserName", 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/getUserInfoByUserName"
dim apiKey as string = "YOURAPIKEY"
dim url as string = gateway & method & "?APIKEY=" & apiKey & "&username=" & username & "&vhost=2"
' 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 getUserInfoByUserName ( username ) {
var params = {
"method" : 'users.getUserInfoByUserName',
"username" : username,
"vhost" : 2}
$.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->getUserInfoByUserName( $username, 2 );
print_r($data);
back to top