This function marks a particular media as offensive.
Note: A user can report a media as offensive once, unless the user id is 1; user id 1 can mark the same media as offensive multiple times.
You can pass various optional parameters to this function, including the id of the user who reported the media as offensive and the reason why the media was reported offensive. If you wish to send an email to a particular person upon the use of this function, then you have to set the following parameters: "templateid" and "to". The "templateid" defines the template to be used for the email, and "to" defines the recipient's email
The variables available in the email are: "media_id", "vhost", "uid", "date" and "reason". Please refer to the table below for more information.
The vhost ID of the media item you want to log as offensive.
mid
int
Required
none
The media ID of the media item that you are going to log as offensive.
parameters
array
Optional
array()
These are various fields that are completely optional. Sample values are: parameters[uid]=1927700 parameters[reason]=inappropriate parameters[templateid]=34529 parameters[to]=your.name@gmail.com
For more information please refer to the "Parameters" table below.
Parameters
The optional parameters that can be passed as an array.
Name
Type
Description
uid
INT
This is the id of the user who is reporting the media item as being offensive
reason
STRING
This is the reason why the user is flagging this media as offensive. Note: This value has a maximum length of 255 characters.
templateid
INT
Set templateid to send an email to a specified user. The recipient's email address is set in the "to" parameter. Note: When "templateid" is set, you need to define tempate variables for the email, as displayed in the "Email Template Parameters" table below.
to
STRING
The e-mail address that the report is going to.
Email Template Parameters
The variables that are available within the email template, for the email that is sent when the parameter templateid is set.
Name
Type
Description
media_id
INT
The id of the media reported as offensive
vhost
INT
The id of the project that contains the media reported as offensive
date
DATETIME
The date and time that the media was reported as offensive
uid
INT
The id of the user who reported the media item as offensive
reason
STRING
The reason why the media was reported as offensive (if provided by the user)
$path = 'https://api.newspark.ca/services/php';
// Listing the arguments
$arguments = array(
'APIKEY' => 'YOURAPIKEY',
'method' => 'media.reportOffensive',
'vhost' => '2',
'mid' => $mid,
'parameters' => $parameters
);
// 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']);
// 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($mid),
XML_RPC_encode($parameters)
);
// Creating an XML-RPC message
$message = new XML_RPC_Message('media.reportOffensive',$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);
/*
* 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 = "reportOffensive";
myRemConn_rc.params = {2:vhost, mid:mid, parameters:parameters};
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);
}
/*
* 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, mid, parameters);
var connection:NetConnection = new NetConnection();
connection.connect(gatewayURL);
connection.call("media.reportOffensive", 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;
}
<%@ 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/reportOffensive"
dim apiKey as string = "YOURAPIKEY"
dim url as string = gateway & method & "?APIKEY=" & apiKey & "&vhost=2" & "&mid=" & mid
' 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 ()
%>
// Get the Service Mapper
$mapper = Sabre_ServiceMap_Mapper::getMapper();
// Calling the method
$data = $mapper->media->reportOffensive( 2, $mid, $parameters );
print_r($data);