Creating or modifying a Clip Interactivity
soporte, ws.webtv, api, clips, interactivity, interactivities

GET vars specific to this request:
| Var | Value | Description |
| go | clips | The API section |
| do | save_interactivity | The API action |
Resulting Request URL:
The resulting request URL would be similar to this (don't forget to append the required info: key, timestamp, salt and signature):
https://....../api.php?go=clips&do=save_interactivity&{required information}
The following POST var is required to create an Interactivity.
| Var | Value | Description |
| id_clip | (int) Clip ID | (Required for creating an Interactivity) ID of the Clip/Ad or -1 in case of a Global Interactivity. |
The following POST var is required to modify an Interactivity.
| Var | Value | Description |
| id | (int) Interactivity ID | (Required for modifying an Interactivity) the Interactivity ID. |
The following POST var are optional.
| Var | Value | Description |
| status | (int) 0/1 | Whether the Interactivity is enabled or disabled |
| closable | (int) 0/1 | Whether the Interactivity is closable |
| on_display_pause | (int) 0/1/2 | Whether to pause the video player when the Interactivity is displayed |
| on_display_mute | (int) 0/1 | Whether to mute the video player when the Interactivity is displayed |
| content | (string) "content" | The Interactivity Content |
| link | (string) "link" | The Interactivity Link |
| width | (int) >0 | The Interactivity width in pixels ... or ... Special values: 1 (the Interactivity will be displayed as full width - having same width as the Video Player). |
| height | (int) >0 | The Interactivity height in pixels ... or ... Special values: 1 (the Interactivity will be displayed as full height - having the same height as the Video Player), 2 (the Interactivity will be displayed as full height minus the player bar height - in case the player bar is visible) |
| Absolute timing case | ||
| [Start Time] | ||
| start_h | (int) >=0 | Hour |
| start_m | (int) >=0 | Minute |
| start_s | (int) >=0 | Second |
| [End Time] | ||
| end_h | (int) >=0 | Hour |
| end_m | (int) >=0 | Minute |
| end_s | (int) >=0 | Second |
| Relative timing case | ||
| [Duration] | ||
| duration_h | (int) >=0 | Hour |
| duration_m | (int) >=0 | Minute |
| duration_s | (int) >=0 | Second |
| [Order] | ||
| relative_position | (int) >=0 | This is the Interactivity position/order respect others from the same Clip. |
If the request was successful, you'll receive a response containing:
• ok: If the Interactivity was created or modified.
• id: The Interactivity ID.
Example:
{
"ok": "The MODIFY operation was performed",
"id": 8961
}
If the request failed (for example, if the Credential does not have permission to GET), you'll receive a response like the following:
{
"error" : "REQUEST_ERROR",
"error_long" : "Permission error: GET"
}
Possible Error Messages
Besides the general errors, this request can return the following errors:
• REQUEST_ERROR | Interactivity does not exist
• MODIFY_ERROR | It was not possible to modify the Interactivity
• CREATE_ERROR | It was not possible to create the Interactivity
• REQUEST_ERROR | Incorrect or missing data for action = [ACTION]
Any other error not covered by the previous cases.
Preparing GET and POST data.
// The GET vars
$GET_VARS = array(
"go" => "clips",
"do" => "save_interactivity"
);
// The POST vars
$POST_VARS = array(
"id" => 8960", // ID of the Interactivity to be modified
"status" => 0 // Disable the interactivity (rest of the properties remain intact)
);
Generating the salt, timestamp, signature and sending the request
*** The following code block is common to all signed requests ***
// Collect the API Base URL and Credential info
$API_URL = "https://www.mywebtvdomain.tv/api.php";
$API_KEY_ID = "1b323a1cb879fd4e66530fbad07a32ee";
$API_SHARED_SECRET = "MWIzMjNhMWNiODc5ZmQ0ZTY2NTMwZmJhZDA3YTMyZWViOTQ3MDJiOGM2ZTU2NjE3"; // keep this safe!!!
// Generating salt and timestamp
$salt = md5(mt_rand());
$timestamp = time();
$signature = base64_encode(hash_hmac('sha256', $salt.$timestamp, $API_SHARED_SECRET, true));
// Generating the validation signature
// - Default method: using base64_encode(hash_hmac(...))
$signature = base64_encode(hash_hmac('sha256', $salt.$timestamp, $API_SHARED_SECRET, true)); // comment this line if using the next method
// - Simplified method - available since v60: using md5().
// This method requires the variable $API_SIGNATURE_GENERATION_MODE = 1; in the config/Config.inc.php file.
// $signature = md5($salt."-".$timestamp."-".$API_SHARED_SECRET); // you must "uncomment" this line when using the simplified method
// Append the timestamp, salt, key and signature to the GET vars
$GET_VARS["timestamp"] = $timestamp; // UTC timestamp
$GET_VARS["salt"] = $salt;
$GET_VARS["key"] = $API_KEY_ID ; // The API Key ID: This is public and is used by the API to identify the application;
$GET_VARS["signature"] = $signature;
// Create the request URL. Please note that if you do not use PHP buit in function
// to create the HTTP query then don't forget to URL encode the values
$REQUEST_URL = $API_URL."?".http_build_query($GET_VARS);
// The previous will build an URL like .../api.php?go=api_subject&do=api_action&etc...
// Create a new cURL resource and set the appropriate options
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $REQUEST_URL);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $POST_VARS);
// If your PHP host does not have a valid SSL certificate, you will need to turn off SSL
// Certificate Verification. This is dangerous (!), and should only be done temporarily
// until a valid certificate has been installed
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // Turns off verification of the SSL certificate.
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Turns off verification of the SSL certificate.
// Sending the request to the API
$response = curl_exec($ch);
// Processing the response
if (!$response) {
echo 'API call failed';
}
else
{
print_r(json_decode($response,true));
}


