Created
February 9, 2020 08:36
-
-
Save alexey-goloburdin/db8f06db70f5e5e22523e16a6b588f0b to your computer and use it in GitHub Desktop.
voximplant_outgoing.html — HTML страница, которая может звонить на мобильные и городские номера телефонов, используя VoxImplant Web SDK. voxengine.js — JS в самом облаке VoxImplant, который обрабатывает звонок и ставит его на запись.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// see YouTube Video about it — https://youtu.be/VcBJmHNSxG4 | |
VoxEngine.addEventListener(AppEvents.CallAlerting, function (e) { | |
call = e.call; | |
callerid = e.destination; | |
call.record(); | |
var pstnCall = VoxEngine.callPSTN(e.destination, 'your_495_or_8800_phone_number'); | |
VoxEngine.easyProcess(e.call, pstnCall); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- see YouTube Video about it — https://youtu.be/VcBJmHNSxG4 --> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<script type="text/javascript" src="//cdn.voximplant.com/edge/voximplant.min.js"></script> | |
<script type="text/javascript"> | |
var initialized = false, // SDK загружено | |
loggedIn = false, // пользователь авторизован | |
connected = false, // получено соединение с VoxImplant сервером | |
voxImplant = VoxImplant.getInstance(); | |
// добавляем прослушивателей основных событий | |
// событие загрузки SDK | |
voxImplant.addEventListener(VoxImplant.Events.SDKReady, handleSDKReady); | |
// событие установки соединения с сервером VoxImplant | |
voxImplant.addEventListener(VoxImplant.Events.ConnectionEstablished, handleConnectionEstablished); | |
// событие авторизации пользователя на сервере VoxImplant | |
voxImplant.addEventListener(VoxImplant.Events.AuthResult, handleAuthResult); | |
// SDK загружен, соединяемся с VoxImplant сервером | |
function handleSDKReady() { | |
initialized = true; | |
voxImplant.connect(); | |
} | |
// соединились с VoxImplant сервером успешно, авторизуем юзера | |
function handleConnectionEstablished() { | |
connected = true; | |
login(); | |
} | |
// проверяем статус авторизации | |
function handleAuthResult(e) { | |
if (e.result) { | |
// Авторизовались успешно | |
loggedIn = true; | |
makeCall(); | |
} | |
} | |
// проводим авторизацию | |
function login(){ | |
// данные созданного пользователя и приложения | |
voxImplant.login("user@application_url", "user_password"); | |
} | |
function makeCall(){ | |
var call = voxImplant.call("phone_number"); // ваш номер для дозвона | |
} | |
function testCall() { | |
// если SDK не инициализирован - проводим процесс | |
if (!initialized) voxImplant.init(); | |
else { | |
// если не установлено соединение с сервером VoxImplant - устанавливаем | |
if (!voxImplant.connected()) voxImplant.connect(); | |
else { | |
// если юзер не авторизован - авторизуем, если авторизован - звоним | |
if (!loggedIn) login(); | |
else makeCall(); | |
} | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<a href="javascript:testCall()">Позвони мне, позвони!</a><br/> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment