The optional "sort" argument is a string that can be used to specify one field to sort the returned groups by.The sort parameter can also include a sort direction ("ASC" or "DESC").
All groups returned will have a last resort sort applied based on the unique group ID to ensure a consistent ordering of groups even when the specified sort field is not unique. Example: sort="membercount DESC" - This will return a list of groups with the groups with the most members first. If multiple groups have the same number of members then the ones with identical member counts will be ordered by ID equivalent to sort="membercount DESC, id".
To arrange the groups or events in the same order as they appear in the tree within MediaFactory you must sort by "treeleft ASC". The fields supported for sorting are: membercount, id, created ,mediacount ,approvedmediacount ,notdeniedmediacount ,name, treeleft.
Name | Type | Required | Default value | Description |
---|
vhost | int | Required | none | The vhost ID that the group belongs to. |
uid | int | Optional | NULL | Filter by and only return groups that the given user ID is a member of. |
moderationStatus | string | Optional | 'accepted' | Filter the group list by the specified moderation status. The possible values are "accepted", "denied", "unmoderated", "moderated", "notdenied","all". |
filters | array | Optional | array() | See the list of possible filters for groups.getGroups service below. |
sort | string | Optional | 'created DESC' | Sets the sort field. Use the format fieldname ASC/DESC. Currently created, distance, membercount, mediacount, id, approvedmediacount, notdeniedmediacount, name, startdate, enddate, and treeleft are supported. To retrieve the groups in the same order they are in the group-event tree use "treeleft ASC". |
startPage | int | Optional | false | Sets the startpage for the group list. This is used with pagination in conjunction with pageSize. The starting page index is 0 (the first page). |
pageSize | int | Optional | false | Sets the total number of items returned per page. This is used with pagination and in conjunction with startPage. The maximum number of groups to include on each page by default is 100 and the maximum is 5000. |
includeTotalCount | bool | Optional | false | If "includeTotalCount" is "true" then the total number of matching groups will be returned along with the groups themselves. If it's "false" then the total count will not be returned. The default for includeTotalCount is false. |
noLimit | bool | Optional | false | You may disable all pagination and limits on the number of groups returned by setting the "noLimit" parameter to "true". This requires the groups.getGroupsNoLimit permission. |
childGroupCount | bool | Optional | false | If "childGroupCount" is "true" then the total number of child groups will be returned for the parengGroupId. If it's "false" then the total count will not be returned. The default for childGroupCount is false. |
groupType | int | Optional | 1 | This is used to specify a specific group type. If a group is not of the specified group type it will not be returned. If a group is a child of a group that is not of the specified group type, it will not be returned. This argument may be one or more of the following values: 1 (groups), 2 (events) 3 (assignments) or null (return all groups, assignments and events).
NB: You may specify multiple groupTypes. For example: passing '1,3' will return data for Groups and Assignments. |
The optional "filters" parameter is an array that may contain the following keys and values.
Name | Type | Description | Default | Possible Values |
---|
creatorUserID | INT | Returns only groups created by the specified user ID. If the user ID specified is not the user that is currently logged in and is not the public user then a check is made for the "groups.getGroups" permission. | empty | INT |
custom1 | STRING | A string that must match the value of the custom1 field of the groups returned. | empty | STRING |
endAfter | DATETIME | Returns groups that end after the specified date. | empty | DATETIME |
endBefore | DATETIME | Returns groups that end before the specified date. | empty | DATETIME |
geoCenter | COORDINATES | Center coordinates to filter from lat,long eg. 43.6355,-79.4245 | empty | COORDINATES |
geoDistance | INT | Distance in meters from geoCenter coordinates | empty | INT |
geoBoundaries | [float LAT, float LNG, float LAT, float LNG] | Return media that is located inside the bounding box made up of the latitude and longitude cooridinites. Specify as an array: [north-west lat, north-west long, south-east lat, south-east long] ([62.86,-52.44,35.08,-131.55]) to receive media within the cooridinites. | empty | [float LAT, float LNG, float LAT, float LNG] |
geo | STRING | Set this to 'notnull' to return only the groups that have valid geo-location values, meaning ones with geo_latitude <> null and geo_longitude <> null | empty |
includeChildren | BOOL | Returns all groups who have parentGroupID as their ancestor. May only be used in combination with the parentGroupID filter. | true | false |
mediaID | INT | A media item that must be present within the groups returned | empty | INT |
parentGroupID | INT | Returns only groups whose parent is the group specified. | INT | INT |
searchDescription | STRING | A string that must exist in the description of the groups returned. | empty | STRING |
searchName | STRING | A string that must exist in the name of the groups returned. | empty | STRING |
searchQuery | STRING | A string that must exist in at least one of the following fields. | empty | name, description, address, host, city |
startAfter | DATETIME | Returns groups that start after the specified date. | empty | DATETIME |
startBefore | DATETIME | Returns groups that start before the specified date. | empty | DATETIME |
The response items returned in a groups.getGroups service call.
Name | Type | Description | Possible Values |
---|
id | INT | The ID of the group. | INT |
name | STRING | The name of the group. | STRING |
description | STRING | A brief blurb about the group. History, purpose, location, ideas, awards, etc. The description is searchable. | STRING |
note | STRING | A note about the group. The note is not searchable. | STRING |
logo | INT | The media ID that is used as the group logo. | INT |
logo_height | INT | The original height of the media being used for the logo. | INT |
logo_width | INT | The original width of the media being used for the logo. | INT |
publicUrl | STRING | The url to access the group logo. The public url will log a hit against the media item when ever loaded. This would be best used on a group details page. | STRING |
thumbUrl | STRING | The url to access the group logo. The thumb url will _NOT_ log a hit against the media item when loaded. This is best used in group galleries or plotting groups on a map. | STRING |
url | STRING | The url of the group. This is used best if the group is for a company, an event with a unique url they wish to also direct traffic to. | STRING |
created | YYYY-MM-DD HH:mm:SS | The date the group was created. | YYYY-MM-DD HH:mm:SS |
createdBy | INT | The user ID of the user who created the group. | INT |
memberCount | INT | The number of members in the group. | INT |
mediaCount | INT | The number of media items in the group. | INT |
approvedMediaCount | INT | The number of approved media items in the group. | INT |
notDeniedMediaCount | INT | The number of not denied media items in the group. | INT |
commentCount | INT | The number of comments in the group. | INT |
approvedCommentCount | INT | The number of approved comments in the group. | INT |
notDeniedCommentCount | INT | The number of not denied comments in the group. | INT |
geo_longitude | LNG | The longitude of the group. This would be specified by the creator of the group. | NUMBER (-52.44) |
geo_latitude | LAT | The latitude of the group. This would be specified by the creator of the group. | NUMBER (62.86) |
moderationStatus | STRING | The current moderation status of the group. | accepted, denied, unmoderated, moderated, notdenied, all |
parentGroup | INT | The ID of the parent group if the current group is a child. | INT |
address | STRING | The address of the group. | STRING |
city | STRING | The city that the group is located in. | INT |
country | STRING | The country that the group is located in. This will be a 2-letter country code. | STRING |
state | STRING | This will be the state/province that the group is located in. It will be a 2-letter state/province code. | STRING |
postalcode | STRING | A valid postal code to contact the group by. | STRING |
newMediaEmailTemplateID | INT | This is the ID of the email template that is sent out when a user uploads media into the group. | INT |
host | STRING | The name of the host who created the group or who is in charge of the group. | STRING |
groupType | INT | This specifies if the group is a group or an event. 1 represents a group, 2 represents an event, and 3 represents an assignment. | 1, 2, 3 |
vhost | INT | The vhost ID that the group belongs to. | INT |
other | ARRAY | An associated array that is used to store any additional information about the group that does not fit in any previous fields. This field is _NOT_ searchable or filterable. This is equivalent to the metadata field for media. | ARRAY |
custom1 | STRING | A searchable and filterable field for any additional information that does not fit into any previous field. | STRING |
treeleft | INT | Used internally for the sorting and ordering groups. | INT |
treeright | INT | Used internally for the sorting and ordering groups. | INT |
email | STRING | The email address to use to allow users to email content to this email address and have it uploaded and entered into the group. | STRING |
distancefromcenter | FLOAT | The number of metres a groups latitude, longitude is from the latitude/longitude specified by geoCenter filter, otherwise this is empty | FLOAT |
totalCount | INT | If the includeTotalCount argument is set to true the total count of groups returned will be included in the response. | INT |
Sample REST Response
http://api.newspark.ca/services/rest/groups/getGroups?vhost=[VHOST_ID]&includeTotalCount=true&filters[includeChildren]=true&filters[parentGroupID]=[PARENT_GROUP_ID]&moderationStatus=all&childGroupCount=true
<?xml version="1.0" encoding="UTF-8"?>
<result>
<childGroupCount>2</childGroupCount>
<item>
<id>GROUP_ID</id>
<name>GROUP_NAME</name>
<description/>
<note/>
<logo>0</logo>
<publicUrl/>
<thumbUrl/>
<url/>
<created>2012-02-03 14:25:30</created>
<createdBy>USER_ID</createdBy>
<memberCount>0</memberCount>
<mediaCount>0</mediaCount>
<approvedMediaCount>0</approvedMediaCount>
<notDeniedMediaCount>0</notDeniedMediaCount>
<geo_longitude>0</geo_longitude>
<geo_latitude>0</geo_latitude>
<moderationStatus>unmoderated</moderationStatus>
<parentGroup>PARENT_GROUP_ID</parentGroup>
<address/>
<city/>
<country/>
<state/>
<postalcode/>
<newMediaEmailTemplateID>0</newMediaEmailTemplateID>
<host/>
<groupType>1</groupType>
<vhost>VHOST_ID</vhost>
<other>
<key>value</key>
</other>
<custom1/>
<treeleft>36</treeleft>
<treeright>37</treeright>
<email/>
</item>
<item>
<id>GROUP_ID</id>
<name>GROUP_NAME</name>
<description/>
<note/>
<logo>0</logo>
<publicUrl/>
<thumbUrl/>
<url/>
<created>2012-02-03 14:25:11</created>
<createdBy>USER_ID</createdBy>
<memberCount>0</memberCount>
<mediaCount>0</mediaCount>
<approvedMediaCount>0</approvedMediaCount>
<notDeniedMediaCount>0</notDeniedMediaCount>
<geo_longitude>0</geo_longitude>
<geo_latitude>0</geo_latitude>
<moderationStatus>unmoderated</moderationStatus>
<parentGroup>PARENT_GROUP_ID</parentGroup>
<address/>
<city/>
<country/>
<state/>
<postalcode/>
<newMediaEmailTemplateID>0</newMediaEmailTemplateID>
<host/>
<groupType>1</groupType>
<vhost>VHOST_ID</vhost>
<other/>
<custom1/>
<treeleft>34</treeleft>
<treeright>35</treeright>
<email/>
</item>
<totalCount>2</totalCount>
</result>
Sample JSON Response
{
"status": true,
"result": {
"0": {
"id": "GROUP_ID",
"name": "GROUP_NAME",
"description": "",
"note": "",
"logo": "0",
"publicUrl": "",
"thumbUrl": "",
"url": "",
"created": "2012-02-13 09:24:24",
"createdBy": "USER_ID",
"memberCount": "0",
"mediaCount": "0",
"approvedMediaCount": "0",
"notDeniedMediaCount": "0",
"geo_longitude": "0",
"geo_latitude": "0",
"moderationStatus": "unmoderated",
"parentGroup": "0",
"address": "",
"city": "",
"country": "",
"state": "",
"postalcode": "",
"newMediaEmailTemplateID": "0",
"host": "",
"groupType": "1",
"vhost": "VHOST_ID",
"other": {
"key": "value"
},
"custom1": "",
"treeleft": "63",
"treeright": "64",
"email": "GROUP_CREATOR_EMAIL_ADDRESS"
},
"1": {
"id": "GROUP_ID",
"name": "GROUP_NAME",
"description": "",
"note": "",
"logo": "0",
"publicUrl": "",
"thumbUrl": "",
"url": "",
"created": "2012-02-13 09:16:29",
"createdBy": "1",
"memberCount": "0",
"mediaCount": "0",
"approvedMediaCount": "0",
"notDeniedMediaCount": "0",
"geo_longitude": "0",
"geo_latitude": "0",
"moderationStatus": "unmoderated",
"parentGroup": "0",
"address": "",
"city": "",
"country": "",
"state": "",
"postalcode": "",
"newMediaEmailTemplateID": "0",
"host": "",
"groupType": "1",
"vhost": "VHOST_ID",
"other": [],
"custom1": "",
"treeleft": "61",
"treeright": "62",
"email": "GROUP_CREATOR_EMAIL_ADDRESS"
}
"childGroupCount": "2",
"totalCount": "2"
}
}
PHP-RPC
$path = 'https://api.newspark.ca/services/php';
// Listing the arguments
$arguments = array(
'APIKEY' => 'YOURAPIKEY',
'method' => 'groups.getGroups',
'vhost' => '2',
'uid' => $uid,
'moderationStatus' => $moderationStatus,
'filters' => $filters,
'sort' => $sort,
'startPage' => $startPage,
'pageSize' => $pageSize,
'includeTotalCount' => $includeTotalCount,
'noLimit' => $noLimit,
'childGroupCount' => $childGroupCount,
'groupType' => $groupType
);
// 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('2'),
XML_RPC_encode($uid),
XML_RPC_encode($moderationStatus),
XML_RPC_encode($filters),
XML_RPC_encode($sort),
XML_RPC_encode($startPage),
XML_RPC_encode($pageSize),
XML_RPC_encode($includeTotalCount),
XML_RPC_encode($noLimit),
XML_RPC_encode($childGroupCount),
XML_RPC_encode($groupType)
);
// Creating an XML-RPC message
$message = new XML_RPC_Message('groups.getGroups',$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(
'2',
$uid,
$moderationStatus,
$filters,
$sort,
$startPage,
$pageSize,
$includeTotalCount,
$noLimit,
$childGroupCount,
$groupType
);
$data = $xmlrpc->invoke('groups.getGroups',$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(
'2',
$uid,
$moderationStatus,
$filters,
$sort,
$startPage,
$pageSize,
$includeTotalCount,
$noLimit,
$childGroupCount,
$groupType
);
$data = $client->call('groups.getGroups',$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 = "groups";
myRemConn_rc.methodName = "getGroups";
myRemConn_rc.params = {2:vhost, uid:uid, moderationStatus:moderationStatus, filters:filters, sort:sort, startPage:startPage, pageSize:pageSize, includeTotalCount:includeTotalCount, noLimit:noLimit, childGroupCount:childGroupCount, groupType:groupType};
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(vhost, uid, moderationStatus, filters, sort, startPage, pageSize, includeTotalCount, noLimit, childGroupCount, groupType);
var connection:NetConnection = new NetConnection();
connection.connect(gatewayURL);
connection.call("groups.getGroups", 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 = "groups/getGroups"
dim apiKey as string = "YOURAPIKEY"
dim url as string = gateway & method & "?APIKEY=" & apiKey & "&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 getGroups ( uid, moderationStatus, filters, sort, startPage, pageSize, includeTotalCount, noLimit, childGroupCount, groupType ) {
var params = {
"method" : 'groups.getGroups',
"vhost" : 2,
"uid" : uid,
"moderationStatus" : moderationStatus,
"filters" : filters,
"sort" : sort,
"startPage" : startPage,
"pageSize" : pageSize,
"includeTotalCount" : includeTotalCount,
"noLimit" : noLimit,
"childGroupCount" : childGroupCount,
"groupType" : groupType}
$.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->groups->getGroups( 2, $uid, $moderationStatus, $filters, $sort, $startPage, $pageSize, $includeTotalCount, $noLimit, $childGroupCount, $groupType );
print_r($data);
back to top