DynTube API
  • Welcome!
  • Key Concepts
  • Quick Start
  • Reference
    • Videos
      • Video Upload via File (Server Side)
      • Video Upload via URL (server side)
      • HTML-Form Client Side Video Uploads
      • Get Video Status
      • Get Videos
      • Get Video
      • Update Video
      • Delete Video
      • Download Original Video
      • Get Video for Mobile App/Custom Player
      • Update Video Image
      • Add Video Captions/Chapters/Subtitles
      • Delete Video Captions/Subtitles/Chapters
      • Create Expirable Links
      • Get Collected Emails
      • Setting Up Webhooks
      • Copy call-to-action (CTA) to Videos
      • Token Authentication
    • Projects
      • Create Project
      • Update a Project
      • Get Projects
      • Get a Project
      • Delete a Project
      • Set default CTA for Project
    • Live Streaming
      • Create a Live Stream
      • Update a Live Stream
      • Get Live Streams
      • Get a Live Stream
      • Count Live Streams
      • Live Streams Limit
      • Get Live Streaming Recording
      • Delete a Live Stream
      • Service and Regions for live streams
    • Channels
      • Get Channels
      • Get Channel
      • Delete Channel
    • Subscriptions
      • Create a Plan
      • Create a Member
      • Attach Plan To Member
      • Get Plans
      • Get Members
      • Get Member's Plans
      • Delete a Plan
    • Analytics
      • Use your User Ids in Analytics
      • Get Video Analytics
    • Javascript Events Methods
      • Plain Javascript Events & Methods
      • Control the Player using React
      • Control the Player in Vue.js
    • Developer Resources
      • How to embed DynTube player in Next.Js
      • How to embed the video player in React
      • How to play DynTube videos in React Native
      • ExoPlayer app to play HLS videos
      • How to embed videos & channels dynamically
      • How to Import Vimeo Videos into DynTube
Powered by GitBook
On this page
  • Request
  • C#
  • Node.js
  • Python
  • PHP
  1. Reference
  2. Videos

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

Name
Type
Description

targetVideos*

Array

List of video Ids.

{
    "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);

PreviousSetting Up WebhooksNextToken Authentication

Last updated 2 years ago