Esta función del API le permite asociar la información de imágenes para un Clip, en la base de datos.
soporte, ws.webtv, api, clips, modificar, images
Variables GET específicas para esta solicitud:
Var | Valor | Descripción |
go | clips | La sección del API |
do | set_image_file_info | La acción del API |
iq | ID Clip | ID del Clip |
URL Resultante:
La URL de solicitud resultante sería similar a la siguiente (no se olvide de añadir la información requerida key, timestamp, salt and signature):
https://....../api.php?go=clips&do=set_image_file_info&iq={id_clip}&{información requerida}
La siguientes variables POST son opcionales.
Var | Value | Description |
img_poster | (string) Nombre archivo imagen poster | Nombre del archivo de imagen - tamaño "poster" [+info] |
img_social | (string) Nombre archivo imagen social | Nombre del archivo de imagen - tamaño "social" [+info] |
img_thumbnail | (string) Nombre archivo imagen miniatura | Nombre del archivo de imagen - tamaño "miniatura"/"thumbnail" [+info] |
img_icon | (string) Nombre archivo imagen icon | Nombre del archivo de imagen - tamaño "icono" [+info] |
sprite_img | (string) Sprite image file name | Nombre del archivo sprite [+info] |
sprite_vtt | (string) Sprite VTT image file name | Nombre del archivo VTT para el sprite [+info] |
NOTA: No suministre la URL de las imágenes, solamente el nombre de los archivos. |
Si la solicitud es exitosa, recibirá una respuesta conteniendo:
• ok: Si el Clip fue modificado exitosamente.
Ejemplo:
{ "ok": "The Clip image file info was correctly set" }
Si la solicitud no es exitosa (por ejemplo, si el ID del Clip no es válido), recibirá una respuesta como la siguiente:
{ "error": "CLIP_NOT_FOUND", "error_long": "It was not possible to find a Clip with the supplied ID" }
Posibles Mensajes de Error
Además de los errores generales, esta solicitud puede devolver los siguientes errores:
• REQUEST_ERROR | Invalid Clip ID:
El ID del Clip no es válido.
• CLIP_NOT_FOUND | It was not possible to find a Clip with the supplied ID:
No se encontró el Clip con el ID especificado.
• MODIFICATION_ERROR | {Mensaje}:
No fue posible modificar el Clip por la razón especificada.
Preparando los datos GET y POST.
// The GET vars $GET_VARS = array( "go" => "clips", "do" => "set_image_file_info", "iq" => 700 ); // The POST vars $POST_VARS = array( "img_poster" => "clip_700_poster.jpg", "img_social" => "clip_700_social.jpg", "img_thumbnail" => "clip_700_thumbnail.jpg", "img_icon" => "clip_700_icon.jpg", "sprite_img" => "clip_700_sprite_image.jpg", "sprite_vtt" => "clip_700_sprite_vtt.vtt" );
Generando salt, timestamp, signature y enviando la solicitud
*** El siguiente bloque de código es común para todas las solicitudes firmadas ***
// Recopilando la información del API y URL Base $API_URL = "https://www.midominiowebtv.tv/api.php"; $API_KEY_ID = "1b323a1cb879fd4e66530fbad07a32ee"; $API_SHARED_SECRET = "MWIzMjNhMWNiODc5ZmQ0ZTY2NTMwZmJhZDA3YTMyZWViOTQ3MDJiOGM2ZTU2NjE3"; // Mantenga esto en un lugar seguro!!! // Generando salt y timestamp $salt = md5(mt_rand()); $timestamp = time(); // Generando la firma de validación // - Método por defecto: usando base64_encode(hash_hmac(...)) $signature = base64_encode(hash_hmac('sha256', $salt.$timestamp, $API_SHARED_SECRET, true)); // comentar esta línea si se utiliza el otro método // - Método simplificado - disponible desde v60: usando md5(). // Este método requiere que la variable $API_SIGNATURE_GENERATION_MODE = 1; en el archivo config/Config.inc.php.
// $signature = md5($salt."-".$timestamp."-".$API_SHARED_SECRET); // debe "des-comentar" esta línea si se utiliza el método simplificado // Añadiendo timestamp, salt, key y signature a las variables GET $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; // Creando la URL de la solicitud. Tenga presente que si no utiliza la función interna de PHP // para crear la solicitud HTTP entonces no se olvide de codificar los valores con URL Encode $REQUEST_URL = $API_URL."?".http_build_query($GET_VARS); // Lo anterior construirá una URL del como .../api.php?go=api_subject&do=api_action&etc... // Creando un recurso cURL con las opciones apropiadas $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. // Enviando la solicitud al API $response = curl_exec($ch); // Procesando la respuesta if (!$response) { echo 'Llamada al API falló'; } else { print_r(json_decode($response,true)); }