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
  • To Assign a Plan to a Member
  • To attach the created plan to the member.
  • Sample JSON Body
  • Code Samples
  • C#
  • Node.js
  • Python
  • PHP
  1. Reference
  2. Subscriptions

Attach Plan To Member

To Assign a Plan to a Member

To attach the created plan to the member.

POST https://api.dyntube.com/v1/member-plans

The content type of the HTTP request should be application/json. Please have a look at the sample JSON body below.

Sample JSON Body

Here is a sample JSON request to create a member-plan.

    {
       "memberId":"meemberId1",
       "planId":"planId1",
       "status":1 //Status 1 is active
    }

Code Samples

C#

using System;
using System.Net.Http;
using System.Text;
using Newtonsoft.Json;

//Note: You will need to add the Newtonsoft.Json package from NuGet to use the `JsonConvert.SerializeObject` method.

namespace CreateMemberPlanExample
{
    class Program
    {
        static async System.Threading.Tasks.Task Main(string[] args)
        {
            string url = "https://api.dyntube.com/v1/member-plans";

            var data = new
            {
                memberId = "memberId1",
                planId = "planId1",
                status = 1
            };

            using (var httpClient = new HttpClient())
            {
                var content = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json");
                var response = await httpClient.PostAsync(url, content);

                if (response.IsSuccessStatusCode)
                {
                    Console.WriteLine("Member plan created successfully.");
                }
                else
                {
                    Console.WriteLine($"Failed to create member plan. Status code: {response.StatusCode}");
                }
            }
        }
    }
}

Node.js

const axios = require('axios');

const data = {
    memberId: 'memberId1',
    planId: 'planId1',
    status: 1
};

axios.post('https://api.dyntube.com/v1/member-plans', data)
    .then((response) => {
        console.log('Member plan created successfully.');
    })
    .catch((error) => {
        console.log(`Failed to create member plan. Status code: ${error.response.status}`);
    });

Python

import requests
import json

url = "https://api.dyntube.com/v1/member-plans"

payload = {
    "memberId": "memberId1",
    "planId": "planId1",
    "status": 1
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_API_KEY"
}

response = requests.post(url, data=json.dumps(payload), headers=headers)

if response.status_code == 200:
    print("Member-plan created successfully.")
else:
    print(f"Failed to create member-plan. Status code: {response.status_code}")

PHP

$url = 'https://api.dyntube.com/v1/member-plans';

$data = array(
    "memberId" => "memberId1",
    "planId" => "planId1",
    "status" => 1
);
$data_json = json_encode($data);

$headers = array(
    'Content-Type: application/json',
    'Authorization: Bearer YOUR_API_KEY'
);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($http_code == 200) {
    echo "Member-plan created successfully.";
} else {
    echo "Failed to create member-plan. Status code: " . $http_code;
}
PreviousCreate a MemberNextGet Plans

Last updated 6 months ago