Requesting a Galleries list
support, ws.webtv, api, galleries, list
GET vars specific to this request:
Var | Value | Description |
go | galleries | 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=galleries&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, id_channel, id_news, status, status_moderation, privacy, privacy_access_level, title, title_url, description, description_seo, tags, img_poster, img_social, img_thumbnail, img_icon, date, views_page, socialize, allow_comments, date_lastmod |
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 Galleriess from the specified User |
statusFilter | (mixed) status | List Galleriess that match the specified status. Available options: 0 (inactive), 1 (active), "any" NOTE: Unsigned requests will only return active Galleriess. |
sortByFilter | (string) "option" | Sort the list. Available options: "date" (lates first - defaul), "title","views_page","id","random","randomSeed", "date2" (reverse date) |
tagsFilter | (string) "tag1,tag2,..." | List Galleriess according to tags (separated by comma). |
idFilter | (string) "ID1,ID2,..." | List Galleriess whose ID matches the specified ones (separated by comma). |
Date filters: | ||
dateFilter | (int) timestamp | List Galleries whose date matches the day of the timestamp (from 00:00:00 to 23:59:59). |
dateStartFilter | (int) timestamp | List Galleries whose date is equal or later respect the day of the timestamp (from 00:00:00) |
dateEndFilter | (int) timestamp | List Galleries whose date is equal or earlier respect the day of the timestamp (up to 23:59:59) |
Category filters: | ||
categoriesFilter | (int) n | List Galleriess associated to the Category. Specify a Category ID or -1 for "orphaned" Galleriess (Galleriess not associated to a Category) |
categoriesFilterStrict | (int) 0/1 | (Depends on the previous option) List Galleriess directly associated with the specified Category (ignoring any Category inheritance). |
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" Galleries 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). |
cvr | (string) "ID1,ID2,..." | CVR = Content View Restriction. This is a list of comma separated Gallery IDs that the current User is not allowed to access. All Galleries matching these IDs will be excluded from the list when excludeForbiddenContent = 1. If cvr is blank then no Galleries will be excluded from the list regardless of the value of excludeForbiddenContent. |
Other filters (Since WS.WebTV 55) |
||
searchableFilter | (int) 0/1 | List Galleries whose "searchable" property matches the value. |
indexableFilter | (int) 0/1 | List Galleries whose "indexable" 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": "4", "list_total": 3, "list": [{ "id": "49", "img_poster": "http:\/\/......\/public\/common\/images\/_default_gallery_poster.gif", "title": "Gallery 1", "user_alias": "WebTV" }, { "id": "40", "img_poster": "http:\/\/......\/uploads\/images\/gallery_40_1409303260_poster.jpg", "title": "Gallery 2", "user_alias": "WebTV" }, { "id": "37", "img_poster": "http:\/\/......\/uploads\/images\/gallery_37_1382608290_poster.jpg", "title": "Gallery 3", "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 Galleriess were found
Preparing GET and POST data.
// The GET vars $GET_VARS = array( "go" => "galleries", "do" => "list" ); // The POST vars $POST_VARS = array( "fields" => "id,title,img_poster", // Include fields id, title and img_poster "paging" => 1, // Allow paging "resultsPerPageFilter" => 3, // Return 3 results per page "current_page" => 1, // Return the page No. 1 "sortByFilter" => "date", // Sort by date "typeFilter" => 1, // List Events only "statusFilter" => "any" // Include items with any status );
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)); }