Changes the properties of a media item.
The options array may contain the following parameters.
Name | Type | Description | Possible Values |
---|
uid | INT | The new user ID for the media item. | INT |
title | STRING | The new title for the media item. | N/A |
message | STRING | The new message for the media item. | N/A |
hidden | STRING | The hidden status of the media item. | HIDDEN or SHOWN |
tags | STRING | Updated tags for the media item. This will overwrite the existing tags with the newly specified tags. | N/A |
moderationstatus | INT | The new moderation status of the media item.
Media Moderation Notifications: Media Moderation notification emails can be sent when media is approved or denied. To send these emails, set the `Approved Moderation Email` and `Denied Moderation Email` templates in the channeldetail page of the channel that the media are in. | 0,1,2,3,-1 (Check the word possibilities unmoderated, accepted, denied, deleted, notdenied, moderated, all) |
channel | INT | The channel ID of the updated channel the media item will be a member of. | INT |
parentid | INT | The new parent ID for the media item. This can be used to assign a media item as a comment along with updating the media context as well or switching a comment from one parent media item to another. | INT |
metadata | ARRAY | The new or updated additional values for the media item. | 'metadata': {'user': {'keyvalue': 'test update'}} |
language | STRING | The 2-letter ISO code that will be used to updated the media's language value. | STRING |
date | YYYY-MM-DD HH:MM:SS | The new date that will be stored for reference to the creation date of the media item. | YYYY-MM-DD HH:MM:SS |
startdate | YYYY-MM-DD HH:MM:SS | The starting date that will be stored for reference for the availability of the media item. | YYYY-MM-DD HH:MM:SS |
enddate | YYYY-MM-DD HH:MM:SS | The ending date that will be stored for reference for the end of availability of the media item. | YYYY-MM-DD HH:MM:SS |
offensive | INT | The number of times that this media has been reported as offensive. | INT |
geo_latitude | FLOAT | The geographic latitude of the file in degrees latitude, specified as a float up to 14 decimals. | 50.00000000000001 |
geo_longitude | FLOAT | The geographic longitude of the file in degrees latitude, specified as a float up to 14 decimals. | -70.00000000000001 |
externalids | ARRAY | This is an array of the third party IDs for the file; it is available only if the file is hosted by one of our partners, such as Twitter, Instagram, Youtube, Brightcove, Widen and Ooyala.
The external id provider values are stored as an integer, and are below: - 0 - other: any provider other than the 7 mentioned below. You can store any reference using this provider.
i.e. 'http://www.arbitrarysite.com/image=123' - 1 - Brightcove
- 2 - Youtube
- 3 - Instagram
- 4 - Twitter
- 5 - Widen
- 6 - Apple
- 7 - Ooyala
NOTE 1 Each recordset in the array is an array itself that contains the following: - external_id (string)
- external_id_provider (integer)
- created (the date the externalid record created/updated)
- vhost
- primary_external_id (Integer. States whether this is the media's primary external id: possible values: 1 or 0.)
.
NOTE 2Only one record can be the primary external id for each media.
NOTE 3The record that is noted as the primary external id is stored in the externalid with the reference to the external id provider stated before the external id.
| Format
array ( < ext. id provider 1 > => '< external id a >', < ext. id provider 2 > => '< external id b >' )
Example 1: Updates media's external ids for Brightcove and Instagram.
array( 1 => '545433_57632' 3 => '545433_57633' )
Example 2: Sets the `primary external id` the media yo 2. NOTEYou can not set the `primary external id` to an externali id that does not exist for the media.
array( 1 => '545433_57632' 3 => '545433_57633' ) |
The response returned on success and failure of media update.
PHP-RPC
$path = 'https://api.newspark.ca/services/php';
// Listing the arguments
$arguments = array(
'APIKEY' => 'YOURAPIKEY',
'method' => 'media.updateFile',
'id' => $id,
'newProperties' => $newProperties,
'options' => $options
);
// 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($options)
);
// Creating an XML-RPC message
$message = new XML_RPC_Message('media.updateFile',$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,
$options
);
$data = $xmlrpc->invoke('media.updateFile',$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,
$options
);
$data = $client->call('media.updateFile',$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 = "media";
myRemConn_rc.methodName = "updateFile";
myRemConn_rc.params = {id:id, newProperties:newProperties, options:options};
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, options);
var connection:NetConnection = new NetConnection();
connection.connect(gatewayURL);
connection.call("media.updateFile", 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 = "media/updateFile"
dim apiKey as string = "YOURAPIKEY"
dim url as string = gateway & method & "?APIKEY=" & apiKey & "&id=" & id & "&newProperties=" & newProperties
' 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 updateFile ( id, newProperties, options ) {
var params = {
"method" : 'media.updateFile',
"id" : id,
"newProperties" : newProperties,
"options" : options}
$.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->media->updateFile( $id, $newProperties, $options );
print_r($data);
back to top