Requesting a Clip or Ad list
support, ws.webtv, api, clips, list
GET vars specific to this request:
Var | Value | Description |
go | clips | The API section |
do | list | 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=list&{required information}
The following list filters are available by using POST vars.
TIP: You can use several filters at the same time.
Var | Value | Description |
fields | (string) "field1,field2,..." | Specify the fields to be included in the result. "*" = all fields (default). "field1, field2, field2" = subset of the fields [Recommended] - separated by comma. Available fields: id, id_user, status, status_moderation, type, privacy, privacy_access_level, title, title_url, description, description_seo, tags, img_poster, img_social, img_thumbnail, img_icon, aspect, duration, date, views, views_complete, views_page, views_embed, clicks, likes, dislikes, is_featured, is_skippable, is_skippable_after, is_3d, socialize, is_ad, ad_link, interactivity_timing, interactivity_spacing, interactivity_start_delay, interactivity_randomization, allow_comments, downloadable, downloadable_xfiles, id_import, date_lastmod, downloadable_condition, store_on_sale, store_play_trailer, is_deletable_only_by_admin |
Embed code generation | ||
generateEmbedCode | (int) 1 | Generate the embed code for each Clip |
embedWidth | (int) width | Width for the embed code (in pixels) |
embedHeight | (int) height | Height for the embed code (in pixels) |
embedURLVars | (string) "&var1=value1..." | Video Player URL vars for the Embed code (check the possible URL vars here) |
Paging options | ||
resultsPerPageFilter | (int) n | Number of results per page |
current_page | (int) n | The number of the current page |
paging | (int) 0/1 | To enable/disable paging |
limit | (int) n | Results limit (only if resultsPerPageFilter is not specified and paging=0) |
Frequently used filters | ||
idUserFilter | (int) author ID | List Clips from the specified User |
statusFilter | (mixed) status | List Clips that match the specified status. Available options: 0 (inactive), 1 (active), 2 (pending moderation), "any", "active", "activeAndApproved", "featured", "featuredActiveAndApproved", "pending", "disapproved", "upcomingInactiveAndApproved", "onsale", "onsaleActiveAndApproved" NOTE: Unsigned requests will only return active and approved Clips. |
sortByFilter | (string) "option" | Sort the list. Available options: "date" (default, last first), "date2" (reverse date), "title", "views_page", "views", "likes", "duration" (shortest first), "duration2" (longest first), "id", "random", "randomSeed", "playlist" |
typeFilter | (mixed) type | List Clips of the specified type. Available options: "any", 0 (Standard), 1 (StreamClip VOD), 2 (StreamClip Live), 3 (EmbedClip), 4 (Auto-Encoding) |
clipAdFilter | (string) "option" | Whether to display Clips, Ads or any. Available options: "any", "clips", "ads" |
tagsFilter | (string) "tag1,tag2,..." | List Clips according to tags (separated by comma). |
idFilter | (string) "ID1,ID2,..." | List Clips whose ID matches the specified ones (separated by comma). |
idImportFilter | (string) "ID1,ID2,..." | List Clips whose Import ID matches the specified ones (separated by comma). |
Date filters | ||
dateFilter | (int) timestamp | List Clips whose date matches the day of the timestamp (from 00:00:00 to 23:59:59). |
dateStartFilter | (int) timestamp | List Clips whose date is equal or later respect the day of the timestamp (from 00:00:00) |
dateEndFilter | (int) timestamp | List Clips whose date is equal or earlier respect the day of the timestamp (up to 23:59:59) |
Channel filters | ||
channelsFilter | (int) n | List Clips included in the Channel Playlist. Specify a Channel ID or -1 for "orphaned" Clips (Clips not associated to a Channel) |
channelsFilterActivePlaylist | (int) 0/1 | (Depends on the previous option) List Clips included only in the active playlist of the specified Channel. |
channelsFilterPlaylist | (int) playlist ID | (Instead of the previous option) List Clips included in the specified Playlist. |
allowRepeated | (int) 0/1 | Since Playlists can contain repeated Clips, with this option you can control when to allow this or not. |
Category filters | ||
categoriesFilter | (int) n | List Clips associated to the Category. Specify a Category ID or -1 for "orphaned" Clips (Clips not associated to a Category) |
categoriesFilterStrict | (int) 0/1 | (Depends on the previous option) List Clips directly associated with the specified Category (ignoring any Category inheritance). |
Directly related News/Event filter - Since WS.WebTV v59 | ||
directRelationshipFilter | (string) "content type" | (This filter is used for listing the Clips related with a particular News/Events...) The type of the directly related content. Available options: "any", "news", "events", "gallery" (future) |
directRelationshipFilterContentID | (int) content ID | ID of the News, Event or Gallery (future) |
Search filters | ||
search | (string) "term" | Term to search |
searchMode | (string) "mode" | The way the system searches for the supplied term. Available options: Standard modes (faster): Look for exact matches. "std1" = search on title + tags. "std2" = search on title + tags + short description. "std3" (default) = search on title + tags + full description. Words modes (slower, find more matches): Search by breaking the term into words and looking for all posible combinations of them. "words1" = search on title + tags. "words2" = search on title + tags + short description. "words3" = search on title + tags + full description. |
Forbidden content exclusion filters - Since WS.WebTV 3.0.2pf1 | ||
excludeForbiddenContent | (int) 0/1 | Whether to exclude "forbidden" Clips from the list. "Forbidden" means that the user is not allowed to access. Note that you must also past the "cvr" variable (see a bit below). |
excludeForbiddenOnSaleContent | (int) 0/1 | (Only if excludeForbiddenContent = 1) Whether to also exclude "forbidden" On Sale Clips from the list. |
cvr | (string) "ID1,ID2,..." | CVR = Content View Restriction. This is a list of comma separated Clip IDs that the current User is not allowed to access. All Clips matching these IDs will be excluded from the list when excludeForbiddenContent = 1. If cvr is blank then no Clips will be excluded from the list regardless of the value of excludeForbiddenContent. |
Custom filters (+info) - Since WS.WebTV 3.0.2pf1 | ||
filterName | (mixed) filter value | Each custom filter must be passed as POST variable |
Likes, favorites, view history filters (use only one of these at a time) - Since WS.WebTV 3.1 (R50) | ||
idUserLikedFilter | (int) User ID | List Clips which were "liked" by the specified User. |
idUserDislikedFilter | (int) User ID | List Clips which were "disliked" by the specified User. |
idUserFavoritedFilter | (int) User ID | List Clips which were added to the "favorites" by the specified User. |
idUserWatchedFilter | (int) User ID | List Clips which were watched by the specified User. |
Other filters | ||
searchableFilter | (int) 0/1 | List Clips whose "searchable" property matches the value. |
indexableFilter | (int) 0/1 | List Clips whose "indexable" property matches the value. |
visitableFilter | (int) 0/1 | List Clips whose "visitable" property matches the value. |
If the request was successful, you'll receive a response containing:
• list_total_found: The total amount of items found in the WebTV which matched the criteria (for paging purpose).
• list_total: The number of items in the returned list. This will normally match the limit or resultsPerPageFilter values.
• list: The item list.
Example:
{ "list_total_found": "157", "list_total": 5, "list": [{ "id": "586", "title": "My Clip", "type": "1", "type_name": "streamclip_vod", "user_alias": "WebTV" }, { "id": "585", "title": "My Live Video", "type": "0", "type_name": "streamclip_live", "user_alias": "WebTV" }] }
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 | No Clips were found
Preparing GET and POST data.
// The GET vars $GET_VARS = array( "go" => "clips", "do" => "list" ); // The POST vars $POST_VARS = array( "fields" => "id,title", // Include only id, and title "paging" => 1, // Allow paging "resultsPerPageFilter" => 5, // Return 5 results per page "current_page" => 1, // Return the page No. 1 "statusFilter" => "any", // Include Clips with any status "sortByFilter" => "date", // Sort Clips by date (latest first) "generateEmbedCode" => 1, // Generate embed code for each Clip "embedWidth" => 400, // Set the Embed code Width = 400px "embedHeight" => 225, // Set the Embed code Height = 225px "embedURLVars" => "&autoplay=1" // Include the Video Player vars in the Embed code );
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)); }