Copy call-to-action (CTA) to Videos

This API endpoint is used to copy all call-to-action (CTAs) from one video to one or more target videos. The CTA configuration contains information about the call-to-action button that appears on the video player, such as the button text, link URL, and other settings.

Request

POST https://api.dyntube.com/v1/videos/{video-id}/cta/copy

The API endpoint requires the following information in the request:

videoId: the ID of the video to copy the CTA configuration from.

targetVideos: an array of one or more video IDs to copy the CTA configuration to. The request must be sent using the HTTP POST method, and the request body must be in JSON format. Target Videos can only be a maximum of 100 per request.

Request Body

{
    "ok": true,
    "message": null,
    "data": {}
}

Sample Codes

Here are sample codes to implement the Dyntube API endpoint in C#, Node.js, Python, and PHP.

C#

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;

namespace DyntubeApiDemo
{
    class Program
    {
        static async Task Main(string[] args)
        {
            var videoId = "12345";
            var targetVideos = new List<string> { "67890", "54321" };
            var apiUrl = $"https://api.dyntube.com/v1/videos/{videoId}/cta/copy";

            using (var client = new HttpClient())
            {
                var token = "[TOKEN]";
                client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);

                var requestBody = new Dictionary<string, List<string>>
                {
                    { "targetVideos", targetVideos }
                };

                var response = await client.PostAsJsonAsync(apiUrl, requestBody);

                if (response.IsSuccessStatusCode)
                {
                    var result = await response.Content.ReadAsStringAsync();
                    Console.WriteLine(result);
                }
                else
                {
                    Console.WriteLine(response.ReasonPhrase);
                }
            }
        }
    }
}

Node.js

const axios = require('axios');

const videoId = '12345';
const targetVideos = ['67890', '54321'];
const apiUrl = `https://api.dyntube.com/v1/videos/${videoId}/cta/copy`;

const requestBody = {
  targetVideos,
};

const config = {
  headers: {
    'Authorization': 'Bearer [TOKEN]',
    'Content-Type': 'application/json'
  }
};

axios.post(apiUrl, requestBody, config)
  .then((response) => {
    console.log(response.data);
  })
  .catch((error) => {
    console.error(error.message);
  });
jav

Python

import requests
import json

video_id = '12345'
target_videos = ['67890', '54321']
api_url = f'https://api.dyntube.com/v1/videos/{video_id}/cta/copy'

request_body = {
    'targetVideos': target_videos
}

headers = {
    'Authorization': 'Bearer [TOKEN]',
    'Content-Type': 'application/json'
}

response = requests.post(api_url, data=json.dumps(request_body), headers=headers)

if response.status_code == 200:
    print(response.json())
else:
    print(response.reason)

PHP

<?php

$videoId = '12345';
$targetVideos = ['67890', '54321'];
$apiUrl = "https://api.dyntube.com/v1/videos/$videoId/cta/copy";

$requestBody = [
  'targetVideos' => $targetVideos,
];

$headers = [
  'Authorization: Bearer [TOKEN]',
  'Content-Type: application/json'
];

$curl = curl_init($apiUrl);

curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($requestBody));
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($curl);

if (!$response) {
  die('Error: ' . curl_error($curl));
}

$responseData = json_decode($response, true);

if ($responseData['status'] === 'success') {
  echo 'CTA configuration copied successfully.';
} else {
  echo 'Error: ' . $responseData['message'];
}

curl_close($curl);

Last updated