Create a Member
Create a New Member
To create a new member.
POST
https://api.dyntube.com/v1/members
The content type of the HTTP request should be application/json. Please have a look at the sample JSON body below.
{
"pager": {
"page": 1,
"size": 12,
"hits": 12,
"total": 1300,
"pages": 109
},
"views": [
{
"id": "NZDSFhZ2",
"videoKey": "NN8GgcLjTsbUg",
"accountKey": "8t9ym1JSJuCZg",
"projectKey": "5lCohVbzSymGw",
"channelKey": "tEOqkbUhB6NOw",
"channelViewId": "NggYmvRvw",
"planType": 1,
"viewerId": "kQdFThzl6e0",
"viewId": "8LsRTyu2S",
"date": "2020-08-01T12:42:14.08+00:00",
"region": "use-s",
"started": true,
"ended": false,
"muted": false,
"duration": 150,
"watchTime": 0,
"browser": {
"family": "Firefox",
"major": 82,
"minor": 0
},
"device": {
"family": "Other",
"brand": "",
"model": "",
"type": "Desktop"
},
"os": {
"family": "Windows",
"major": 10,
"processor": "x64"
},
"geo": {
"ip": "121.121.60.0",
"city": "Kuala Lumpur",
"country": "MY",
"region": "Kuala Lumpur",
"continent": "AS"
},
"embed": {
"url": "https://www.dyntube.com/",
"domain": "www.dyntube.com",
"type": 1
},
"userKey": ""
}
]
}
Sample JSON Body
Here is a sample JSON request to create a member.
{
"username": "foo@bar.com",
"password":"Abcd1234", //8 letter including capital, lower case and a number
"status":1 //Status 1 is active
}
Code Samples
C#
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace CreateMemberDemo
{
class Program
{
static async Task Main(string[] args)
{
string url = "https://api.dyntube.com/v1/members";
var member = new
{
username = "foo@bar.com",
password = "Abcd1234",
status = 1
};
using (var httpClient = new HttpClient())
{
var json = JsonSerializer.Serialize(member);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await httpClient.PostAsync(url, content);
if (response.IsSuccessStatusCode)
{
Console.WriteLine("Member created successfully");
}
else
{
Console.WriteLine($"Failed to create member. Status code: {response.StatusCode}");
}
}
}
}
}
Node.js
const https = require('https');
const data = JSON.stringify({
username: 'foo@bar.com',
password: 'Abcd1234',
status: 1
});
const options = {
hostname: 'api.dyntube.com',
port: 443,
path: '/v1/members',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': data.length
}
};
const req = https.request(options, (res) => {
let responseData = '';
res.on('data', (chunk) => {
responseData += chunk;
});
res.on('end', () => {
if (res.statusCode === 200) {
console.log('Member created successfully');
} else {
console.log(`Failed to create member. Status code: ${res.statusCode}`);
}
});
});
req.on('error', (error) => {
console.error(error);
});
req.write(data);
req.end();
Python
import requests
url = "https://api.dyntube.com/v1/members"
payload = {
"username": "foo@bar.com",
"password": "Abcd1234", # 8 characters including at least one uppercase letter, one lowercase letter, and a number
"status": 1 # 1 for active status
}
headers = {
"Content-Type": "application/json",
}
response = requests.post(url, headers=headers, json=payload)
if response.status_code == 200:
print("Member created successfully.")
else:
print("Failed to create member. Status code:", response.status_code)
PHP
<?php
$data = array(
'username' => 'foo@bar.com',
'password' => 'Abcd1234',
'status' => 1
);
$data_string = json_encode($data);
$ch = curl_init('https://api.dyntube.com/v1/members');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string)
));
$result = curl_exec($ch);
if ($result) {
echo "Member created successfully.";
} else {
echo "Failed to create member.";
}
curl_close($ch);
?>
Last updated