mirror of https://github.com/aiden09/mirotalksfu
[mirotalksfu] - add API join endpoint + swagger doc
parent
e678180b43
commit
05ed18f543
@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
const fetch = require('node-fetch');
|
||||
|
||||
const API_KEY = 'mirotalksfu_default_secret';
|
||||
const MIROTALK_URL = 'http://localhost:3010/api/v1/join';
|
||||
|
||||
function getResponse() {
|
||||
return fetch(MIROTALK_URL, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
authorization: API_KEY,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
room: 'test',
|
||||
name: 'mirotalksfu',
|
||||
audio: true,
|
||||
video: true,
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
getResponse().then(async (res) => {
|
||||
console.log('Status code:', res.status);
|
||||
const data = await res.json();
|
||||
console.log('join:', data.join);
|
||||
});
|
||||
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
$API_KEY = "mirotalksfu_default_secret";
|
||||
$MIROTALK_URL = "http://localhost:3010/api/v1/join";
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $MIROTALK_URL);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
|
||||
$headers = [
|
||||
'authorization:' . $API_KEY,
|
||||
'Content-Type: application/json'
|
||||
];
|
||||
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
|
||||
$data = array(
|
||||
"room" => "test",
|
||||
"name" => "mirotalksfu",
|
||||
"audio" => true,
|
||||
"video" => true,
|
||||
);
|
||||
$data_string = json_encode($data);
|
||||
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
|
||||
$response = curl_exec($ch);
|
||||
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
echo "Status code: $httpcode \n";
|
||||
$data = json_decode($response);
|
||||
echo "join: ", $data->{'join'}, "\n";
|
||||
@ -0,0 +1,27 @@
|
||||
import requests
|
||||
import json
|
||||
|
||||
API_KEY = "mirotalksfu_default_secret"
|
||||
MIROTALK_URL = "http://localhost:3010/api/v1/join"
|
||||
|
||||
headers = {
|
||||
"authorization": API_KEY,
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
data = {
|
||||
"room": "test",
|
||||
"name": "mirotalksfu",
|
||||
"audio": "true",
|
||||
"video": "true",
|
||||
}
|
||||
|
||||
response = requests.post(
|
||||
MIROTALK_URL,
|
||||
headers=headers,
|
||||
json=data,
|
||||
)
|
||||
|
||||
print("Status code:", response.status_code)
|
||||
data = json.loads(response.text)
|
||||
print("join:", data["join"])
|
||||
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
API_KEY="mirotalksfu_default_secret"
|
||||
MIROTALK_URL="http://localhost:3010/api/v1/join"
|
||||
|
||||
curl $MIROTALK_URL \
|
||||
--header "authorization: $API_KEY" \
|
||||
--header "Content-Type: application/json" \
|
||||
--data '{"room":"test","name":"mirotalksfu","audio":"1","video":"1"}' \
|
||||
--request POST
|
||||
Loading…
Reference in New Issue