Use this method to vote on the media item.
The responses returned by the getFileInfo service call. Below is a list of all the information returned for a piece of media using the media.getFileInfo service call.
Name | Description | Possible Values |
---|
id | The media ID of the requested media. | INT |
status | The upload status of the media ID requested. | 0,1,2,3 |
contenttype | The mimetype of the file, for example: audio/mp3. | MIMETYPE |
filetype | The filetype of the requested media item. | 0,1,2,3,4 |
context | The context of the media item. This will be if it is a note, comment, entry etc. | 0,1,2,3 |
filename | The original file name of the uploaded media item. | string/empty |
injector | A user-defined string, allows tracking where a file was inserted from. | videomixer, feedImporter2, httpupload, MediaFactory.com |
hits | The number of views the media received. | INT |
message | The message of the media item. | STRING |
date | The date and time for when the file started to be uploaded into MediaFactory. | YYYY-MM-DD HH:MM:SS |
title | The title of the media item. | STRING |
tags | All the tags associated with the piece of media. Each tag is separated by a space. | STRING |
extension | The original file extension of the uploaded media item. An example would be png. | STRING |
sender | The email address, populated by the email injector. | STRING |
author | DEPRECATED | empty |
metadata | An ARRAY for any additional information that is to be stored with the media item. It is stored as an associated array in this field. | {'user' : {'key' : 'value'}} |
uid | The ID of the user who uploaded the media into the system. | INT |
filesize | The size of the file, in bytes. | INT |
ofilesize | The original filesize of the media in KB. | INT |
upload | The upload date of the when the file was first uploaded into MediaFactory. | YYYY-MM-DD HH:MM:SS |
location | The server location of the uploaded media item. | STRING (s3, fmlocal, fmdevs3) |
originallocation | The location of where the original file is stored. | s3, fmlocal, fmdevs3 |
privacy | DEPRECATED | DEPRECATED |
moderationstatus | The current moderation status of the file. | 0,1,2,3,-1 |
width | The original width of the file in pixels. | INT |
height | The original height of the file in pixels. | INT |
length | The duration of the file in as a floating point number in seconds. (example: 187.33, for 3 minutes, 7 seconds) | NUMBER |
conversiontime | The time it took to convert the file. | INT(seconds) |
converttime | The date and time the transcoding of the file was completed. | YYYY-MM-DD HH:MM:SS |
lastupdatetime | The date and time of the last update which was made to the file. | YYYY-MM-DD HH:MM:SS |
offensive | DEPRECATED | DEPRECATED |
rating | The rating of the file. | INT |
votecount | The vote count of the file. | INT |
externalid | This is the third party ID of 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.
NOTE 1 The external id does not always state the external id provider.
NOTE 2 It is equal to the primary media externalids reference, with the provider being stated in the reference, while in the externalids the provider is stored in the array as `external_id_provider`.
Example: instagram_image:678386240811661326_1187731501ments ( Brightcove ). This does not state the external id provider. | STRING |
parentid | The parent ID of the media item. This would be specified if the media item was a comment. This would be the ID of the media which the commented was made on. | INT |
originalLocation | The location of where the original file is stored. | s3, fmlocal, fmdevs3 |
user_name | The user name of the submitter. | STRING |
user_email | The email of the submitter. | STRING |
user_country | The 2-letter country code of the submitter. | STRING |
user_city | The city of the submitter. | empty,STRING |
user_state | The 2-letter state or province code of submitter. | STRING |
user_nickname | The submitter's nickname. | STRING |
user_firstname | The submitter's firstname. | empty,STRING |
user_lastname | The last name of the user who uploaded the file. | STRING |
url | The URL that could be associated with a media item. | STRING |
vhost | The ID of the vhost which the file belongs to. | INT |
language | The 2-character ISO language code. | STRING |
channel | The channel ID the file is a member of. | INT |
channel_shortname | The given short name the file is a member of. | STRING (sample_shortname) |
channel_name | The channel name the file belongs to. | STRING |
channelleft | The position INT of the channel relative to walking a left channel tree. | INT |
geo_latitude | The latitude of the file. This is added via dropping the pin on the map upon upload. | NUMBER (62.86) |
geo_longitude | The longitude of the file. This is added via dropping the pin on the map upon upload. | NUMBER (-52.44) |
hidden | The visibility of the file. | HIDDEN, SHOWN, or ALL |
commentcount | The total number of comments made on the file. | INT |
approvedcomments | The total number of approved comments made on the file. | INT |
notdeniedcomments | The total number of not denied comments made on the file. | 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 |
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/media/vote?mid=[MEDIA_ID]&vote=[1 or 0]&recaptcha=[TRUE/FALSE]
// To be added later
Sample JSON Response
{
"status": true,
"result": {
"id": MEDIA_ID,
"status": 3,
"contenttype": "image/jpeg",
"filetype": 1,
"context": 1,
"filename": "316911_10150323267562762_165749722761_8170951_475289856_n.jpeg",
"injector": "httpupload",
"hits": 3,
"message": "MEDIA_DESCRIPTION",
"date": "2012-02-13 16:35:09",
"title": "MEDIA_TITLE",
"tags": "",
"extension": "jpeg",
"sender": "",
"author": "",
"metadata": "a:1:{s:4:\"exif\";a:7:{s:8:\"FileName\";s:9:\"phpC1hTFe\";s:12:\"FileDateTime\";i:1329168909;s:8:\"FileSize\";i:37193;s:8:\"FileType\";i:2;s:8:\"MimeType\";s:10:\"image/jpeg\";s:13:\"SectionsFound\";s:7:\"COMMENT\";s:7:\"COMMENT\";a:1:{i:0;s:1:\"*\";}}}",
"uid": USER_ID,
"filesize": 37193,
"ofilesize": 51456,
"upload": "2012-02-13 16:35:09",
"location": "fmdevs3",
"originallocation": "",
"privacy": 0,
"moderationstatus": 0,
"width": 586,
"height": 394,
"length": "0.00",
"conversiontime": "2.07566",
"converttime": "2012-02-13 16:35:14",
"lastupdatetime": "2012-02-15 09:58:28",
"offensive": 0,
"autoblog": "0",
"rating": 10,
"votecount": 1,
"externalid": "",
"parentid": 0,
"originalLocation": "",
"user_name": "USER_NAME",
"user_email": "USER_EMAIL_ADDRESS",
"user_country": "CA",
"user_city": "Toronto",
"user_state": "ON",
"user_nickname": "",
"user_firstname": "USER_FIRSTNAME",
"user_lastname": "USER_LASTNAME",
"url": "",
"vhost": VHOST_ID,
"rotation": 0,
"language": "",
"channel": 0,
"channel_shortname": null,
"channel_name": null,
"channelleft": 0,
"geo_latitude": null,
"geo_longitude": null,
"originalsaved": 1,
"hidden": "SHOWN",
"commentcount": 0,
"approvedcomments": 0,
"notdeniedcomments": 0,
"publicUrl": "http://fmdevs3.filemobile.com/storage/MEDIA_ID",
"thumbUrl": "http://fmdev.s3.amazonaws.com/storage/MEDIA_ID",
"moderationdeniedid": 0
}
}
PHP-RPC
$path = 'https://api.newspark.ca/services/php';
// Listing the arguments
$arguments = array(
'APIKEY' => 'YOURAPIKEY',
'method' => 'media.vote',
'mid' => $mid,
'vote' => $vote,
'recaptcha' => $recaptcha,
'uid' => $uid,
'APIKEY' => $APIKEY
);
// 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($mid),
XML_RPC_encode($vote),
XML_RPC_encode($recaptcha),
XML_RPC_encode($uid),
XML_RPC_encode($APIKEY)
);
// Creating an XML-RPC message
$message = new XML_RPC_Message('media.vote',$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(
$mid,
$vote,
$recaptcha,
$uid,
$APIKEY
);
$data = $xmlrpc->invoke('media.vote',$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(
$mid,
$vote,
$recaptcha,
$uid,
$APIKEY
);
$data = $client->call('media.vote',$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 = "vote";
myRemConn_rc.params = {mid:mid, vote:vote, recaptcha:recaptcha, uid:uid, APIKEY:APIKEY};
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(mid, vote, recaptcha, uid, APIKEY);
var connection:NetConnection = new NetConnection();
connection.connect(gatewayURL);
connection.call("media.vote", 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/vote"
dim apiKey as string = "YOURAPIKEY"
dim url as string = gateway & method & "?APIKEY=" & apiKey & "&mid=" & mid & "&vote=" & vote
' 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 vote ( mid, vote, recaptcha, uid, APIKEY ) {
var params = {
"method" : 'media.vote',
"mid" : mid,
"vote" : vote,
"recaptcha" : recaptcha,
"uid" : uid,
"APIKEY" : APIKEY}
$.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->vote( $mid, $vote, $recaptcha, $uid, $APIKEY );
print_r($data);
back to top