Returns the list of channels for the specified vhost.
This is the response received on success of the getChannels method call. If there are no channels in your vhost you will be returned an empty XML response.
Name | Type | Description | Possible Values |
---|
id | INT | The current channel ID. | INT channel ID |
created | YYYY-MM-DD HH:MM:SS | The date the channel was created. | YYYY-MM-DD HH:MM:SS |
vhost | INT | The vhost ID. | INT |
name | STRING | The channel name defined in MediaFactory. | STRING |
shortname | STRING | The given short given retrieved in MediaFactory. By Default this is the channel name, all lowercase and have spaces " " replaced by underscores "_". | STRING |
parentchannel | INT | The ID of the current channel's parent. This is for nested channel lists. | INT |
thumburl | STRING | OBSOLETE | STRING |
status | INT | The moderation status of the current channel. | 0,1,2,3,4 |
description | STRING | A short summary for the purpose of the channel. This is defined in MediaFactory. | STRING |
readonly | INT | OBSOLETE | 0/1 |
disableembed | INT | DEPRECATED | 0/1 |
modemailaccepted | INT | The ID of the email to use for Media approved in the channel. | INT |
modemaildenied | INT | The moderation email ID of the email to use for Media denied in the channel. | INT |
emailaddress | STRING | Email address to be used for media intake through email. Leave empty to disable, must be unique. | STRING |
defaultsort | STRING | The default sort order of the media within the channel. | 'name ASC', 'name DESC', 'shortname ASC', 'shortname DESC', 'id ASC', 'id DESC', 'createdDate ASC', 'createdDate DESC' |
visibility | STRING | The current visibility of the channel. | SHOWN, HIDDEN |
geoblocking | STRING | A list of accepted country codes to have the content from the channel display. This setting is set in the channel settings. | ca,us,au etc. |
groupid | DEPRECATED | DEPRECATED | DEPRECATED |
groupname | DEPRECATED | DEPRECATED | DEPRECATED |
Sample REST Response
http://api.newspark.ca/services/rest/channels/getChannels?vhost=[VHOST_ID]
<?xml version="1.0" encoding="UTF-8"?>
<result>
<item>
<id>CHANNEL_ID</id>
<created>2012-01-20 12:08:57</created>
<vhost>VHOST_ID</vhost>
<name>Comments</name>
<shortname>comments</shortname>
<parentchannel>0</parentchannel>
<thumburl/>
<status>1</status>
<description/>
<readonly>0</readonly>
<disableembed>0</disableembed>
<modemailaccepted>0</modemailaccepted>
<modemaildenied>0</modemaildenied>
<emailaddress/>
<defaultsort>upload DESC</defaultsort>
<visibility>SHOWN</visibility>
<geoblocking/>
<groupid>0</groupid>
<groupname/>
</item>
<item>
<id>CHANNEL_ID</id>
<created>2012-01-20 12:08:44</created>
<vhost>VHOST_ID</vhost>
<name>Documentation</name>
<shortname>documentation</shortname>
<parentchannel>0</parentchannel>
<thumburl/>
<status>1</status>
<description/>
<readonly>0</readonly>
<disableembed>0</disableembed>
<modemailaccepted>4266</modemailaccepted>
<modemaildenied>0</modemaildenied>
<emailaddress/>
<defaultsort>upload DESC</defaultsort>
<visibility>SHOWN</visibility>
<geoblocking/>
<groupid>0</groupid>
<groupname/>
</item>
</result>
Sample JSON Response
{
"status": true,
"result": [
{
"id": "CHANNEL_ID",
"created": "2012-01-20 12:08:57",
"vhost": "VHOST_ID",
"name": "Comments",
"shortname": "comments",
"parentchannel": "0",
"thumburl": "",
"status": "1",
"description": "",
"readonly": "0",
"disableembed": "0",
"modemailaccepted": "0",
"modemaildenied": "0",
"emailaddress": null,
"defaultsort": "upload DESC",
"visibility": "SHOWN",
"geoblocking": null,
"groupid": "0",
"groupname": ""
},
{
"id": "CHANNEL_ID",
"created": "2012-01-20 12:08:44",
"vhost": "VHOST_ID",
"name": "Documentation",
"shortname": "documentation",
"parentchannel": "0",
"thumburl": "",
"status": "1",
"description": "",
"readonly": "0",
"disableembed": "0",
"modemailaccepted": "4266",
"modemaildenied": "0",
"emailaddress": null,
"defaultsort": "upload DESC",
"visibility": "SHOWN",
"geoblocking": null,
"groupid": "0",
"groupname": ""
}
]
}
PHP-RPC
$path = 'https://api.newspark.ca/services/php';
// Listing the arguments
$arguments = array(
'APIKEY' => 'YOURAPIKEY',
'method' => 'channels.getChannels',
'vhost' => '2',
'order' => $order,
'visibility' => $visibility,
'parentchannel' => $parentchannel
);
// 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($order),
XML_RPC_encode($visibility),
XML_RPC_encode($parentchannel)
);
// Creating an XML-RPC message
$message = new XML_RPC_Message('channels.getChannels',$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',
$order,
$visibility,
$parentchannel
);
$data = $xmlrpc->invoke('channels.getChannels',$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',
$order,
$visibility,
$parentchannel
);
$data = $client->call('channels.getChannels',$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 = "channels";
myRemConn_rc.methodName = "getChannels";
myRemConn_rc.params = {2:vhost, order:order, visibility:visibility, parentchannel:parentchannel};
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, order, visibility, parentchannel);
var connection:NetConnection = new NetConnection();
connection.connect(gatewayURL);
connection.call("channels.getChannels", 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 = "channels/getChannels"
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 getChannels ( order, visibility, parentchannel ) {
var params = {
"method" : 'channels.getChannels',
"vhost" : 2,
"order" : order,
"visibility" : visibility,
"parentchannel" : parentchannel}
$.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->channels->getChannels( 2, $order, $visibility, $parentchannel );
print_r($data);
back to top