This method returns the collection info along with media in the collection based upon the collection ID requested.
This method returns two arrays, "info" and "data". The "info" array holds the collection ID information where the "data" array holds a list of arrays for each media item in the collection.
Name | Type | Description | Default Values |
---|
id | INT | The collection ID | INT |
vhost | INT | The vhost ID that the collection belongs to. | INT |
thumbnail | STRING | A thumb url of an image to represent the collection. | empty STRING |
type | INT | This determines whether the collection is a saved search collection or a manual collection. Saved search is represented by 1 and manual collection by 2. | 1/2 |
name | STRING | The name of the collection. This is used for recognition of the channel. | STRING |
description | STRING | An overview of the media content that is in the collection. | STRING |
created | YYYY-MM-DD HH:MM:SS | The date the collection was created in our system. | YYYY-MM-DD HH:MM:SS |
baseurl | STRING | DEPRECATED | STRING |
channel | INT | The channel that is used as a filter if the collection type is a saved search. | empty / channel ID |
addtotop | INT | When this is set the channel will be added to the top of the channel list. | 0/1 |
autoactive | INT | This sets the collection that it will be set as published as its default state. | 0/1 |
The Response Data contains the data for media in the collection.
This part of the response is the same as the data returned by the media.getFileInfo service call.
Name | Description | Possible Values |
---|
id | The media ID of the requested media. | INT |
vhost | The ID of the vhost which the file belongs to. | INT |
publicUrl | The publicly accessible url of the media item. This url will log a hit on the piece of media. | STRING |
thumbUrl | the publicly accessible url used only as a thumbnail for the piece of media. Using the thumb url will NOT log a hit on the media item. | STRING |
extension | The original file extension of the uploaded media item. An example would be png. | STRING |
filename | The original file name of the uploaded media item. | string/empty |
filetype | The filetype of the requested media item. | 0,1,2,3,4 |
hits | The number of views the media received. | INT |
message | The message of the media item. | STRING |
moderationstatus | The current moderation status of the file. | 0,1,2,3,-1 |
position | The position media item in the collection list. | INT |
rating | The rating of the file. | INT |
tags | All the tags associated with the piece of media. Each tag is separated by a space. | STRING |
title | The title of the media item. | STRING |
uid | The ID of the user who uploaded the media into the system. | INT |
upload | The upload date of the when the file was first uploaded into MediaFactory. | YYYY-MM-DD HH:MM:SS |
user_name | The user name of the submitter. | STRING |
user_nickname | The submitter's nickname. | STRING |
votecount | The vote count of the file. | INT |
location | The server location of the uploaded media item. | STRING (s3, fmlocal, fmdevs3) |
moderationdeniedid | The moderation reason for being denied. | Possible values for denied reasons are 0-14. Exact reasons are available in our glossary. |
Sample REST Response
http://api.newspark.ca/services/rest/collections/getCollectionData?collection=[COLLECTION_ID]
<?xml version="1.0" encoding="UTF-8"?>
<result>
<info>
<id>COLLECTION_ID</id>
<vhost>VHOST_ID</vhost>
<thumbnail/>
<type>1</type>
<name>COLLECTION_NAME</name>
<description>COLLECTION_DESCRIPTION</description>
<created>2012-02-03 11:40:39</created>
<baseurl/>
<channel>0</channel>
<addToTop>0</addToTop>
<autoActive>1</autoActive>
</info>
<data>
<item>
<extension>png</extension>
<filename>filemobile_lydhz6cTvy1qcnl1ho1_500.png</filename>
<filetype>1</filetype>
<hits>49</hits>
<id>MEDIA_ID</id>
<message>MEDIA_MESSAGE</message>
<moderationstatus>2</moderationstatus>
<position>4</position>
<rating>0</rating>
<tags>media example test upload</tags>
<title>MEDIA_TITLE</title>
<uid>USER_ID</uid>
<upload>2012-01-25 16:36:47</upload>
<user_name>USER_NAME</user_name>
<user_nickname/>
<vhost>VHSOT_ID</vhost>
<votecount>0</votecount>
<publicUrl>http://fmdevs3.filemobile.com/storage/MEDIA_ID</publicUrl>
<thumbUrl>http://fmdev.s3.amazonaws.com/storage/MEDIA_ID</thumbUrl>
<location>fmdevs3</location>
<moderationdeniedid>2</moderationdeniedid>
</item>
</data>
</result>
Sample JSON Response
{
"status": true,
"result": {
"info": {
"id": COLLECTION_ID,
"vhost": VHOST_ID,
"thumbnail": null,
"type": 1,
"name": "COLLECTION_NAME",
"description": "COLLECTION_DESCRIPTION",
"created": "2012-02-03 11:40:39",
"baseurl": null,
"channel": 0,
"addToTop": 0,
"autoActive": 1
},
"data": [
{
"extension": "png",
"filename": "filemobile_lydhz6cTvy1qcnl1ho1_500.png",
"filetype": 1,
"hits": 49,
"id": MEDIA_ID,
"message": "MEDIA_MESSAGE",
"moderationstatus": 2,
"position": "4",
"rating": 0,
"tags": "media example test upload",
"title": "MEDIA_TITLE",
"uid": USER_ID,
"upload": "2012-01-25 16:36:47",
"user_name": "USER_NAME",
"user_nickname": "",
"vhost": VHOST_ID,
"votecount": 0,
"publicUrl": "http://fmdevs3.filemobile.com/storage/MEDIA_ID",
"thumbUrl": "http://fmdev.s3.amazonaws.com/storage/MEDIA_ID",
"location": "fmdevs3",
"moderationdeniedid": 2
}
]
}
}
PHP-RPC
$path = 'https://api.newspark.ca/services/php';
// Listing the arguments
$arguments = array(
'APIKEY' => 'YOURAPIKEY',
'method' => 'collections.getCollectionData',
'collection' => $collection,
'editMode' => $editMode,
'sane_metadata' => $sane_metadata
);
// 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($collection),
XML_RPC_encode($editMode),
XML_RPC_encode($sane_metadata)
);
// Creating an XML-RPC message
$message = new XML_RPC_Message('collections.getCollectionData',$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(
$collection,
$editMode,
$sane_metadata
);
$data = $xmlrpc->invoke('collections.getCollectionData',$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(
$collection,
$editMode,
$sane_metadata
);
$data = $client->call('collections.getCollectionData',$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 = "collections";
myRemConn_rc.methodName = "getCollectionData";
myRemConn_rc.params = {collection:collection, editMode:editMode, sane_metadata:sane_metadata};
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(collection, editMode, sane_metadata);
var connection:NetConnection = new NetConnection();
connection.connect(gatewayURL);
connection.call("collections.getCollectionData", 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 = "collections/getCollectionData"
dim apiKey as string = "YOURAPIKEY"
dim url as string = gateway & method & "?APIKEY=" & apiKey & "&collection=" & collection
' 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 getCollectionData ( collection, editMode, sane_metadata ) {
var params = {
"method" : 'collections.getCollectionData',
"collection" : collection,
"editMode" : editMode,
"sane_metadata" : sane_metadata}
$.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->collections->getCollectionData( $collection, $editMode, $sane_metadata );
print_r($data);
back to top