Home

WTAPI

WTAPI for WEB is a Java Script Telephony API. Using WTAPI it is possible to control supported devices connected to the PBX.

Supported in WMS 5.0+

Quick start

Go to your PBX WMS -> Settings ->PBX -> Integration -> OAuth 2.0 applications

Add new OAuth2 application.

Enter application name and redirect URI.

For webapi demo Redirect URI is https://www.wildix.com/webapi/v2/demo/oauth2redirect.html

Save application and copy Application ID.

Make index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <script src="../dist/wtapi.v2.js"></script>
    <script>
        function oauth2Callback(params) {
            api.handleCallbackData(params);
        }

        var api = new WTAPI();

        api.setOptions({
            pbxUrl: 'your_pbx_domain.wildixin.com',
            applicationId: 'oauth2_application_id',
            redirectUri: 'https://your_domain/oauth2redirect.html',
        });

        api.on('connected', () => {
            console.log('Connected');
        });
        api.on('disconnected', () => {
            console.log('Disconnected');
        });

        api.on('oauthAuthorizationError', (error) => {
            console.error('OAuth authorization error', error);
        });
        api.on('oauthAuthorizationSuccess', (data) => {
            console.log('OAuth authorization success', data);
        });

        api.connect();
    </script>
</head>
<body>
</body>
</html>

Make oauth2redirect.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>OAuth Redirect callback page</title>
    <script src="../dist/wtapi.v2.js"></script>
</head>
<body>
<script>
    const wtapi = new WTAPI();
    wtapi.handleAuthorizationResponse();
</script>
</body>
</html>

Go to https://your_domain/index.html and see the browser dev console.