API Version: 6.4
https://pabx.hostname/
which will need substituting for the actual URL/hostname of the IPCortex Communication System (CS) which the application is to run against. It is necessary to use HTTPS in order to avoid the browser complaining about cross-site scripting and insecure data in the page.<head>
tag. It is then necessary for the page (or an included application) to call:<!doctype html>
<html>
<head>
<title>IPC</title>
<script src="https://pabx.hostname/api/api.js"></script>
</head>
<body>
<script>
var TAG = 'IPC:';
IPCortex.PBX.Auth.setHost('https://pabx.hostname');
/* Display a login prompt */
IPCortex.PBX.Auth.login().then(
function() {
console.log(TAG, 'Login successful');
/* Get the API to start collecting data */
IPCortex.PBX.startFeed().then(
function() {
console.log(TAG, 'Live data feed started');
runApp();
},
function() {
console.log(TAG, 'Live data feed failed');
}
);
},
function() {
console.log(TAG, 'Login failed');
}
);
function runApp() {
/* Implement application here */
}
</script>
</body>
</html>
onAPILoadReady()
function:<!doctype html>
<html>
<head>
<title>IPC</title>
<script src="http://pabx.hostname/api/wrapper.whtm"></script>
</head>
<body>
<script>
var TAG = 'IPC:';
/* Wait for API to confirm it is loaded - setHost() is called automatically for us */
function onAPILoadReady() {
/* Display a login prompt */
IPCortex.PBX.Auth.login().then(
function() {
console.log(TAG, 'Login successful');
/* Get the API to start collecting data */
IPCortex.PBX.startFeed().then(
function() {
console.log(TAG, 'Live data feed started');
runApp();
},
function() {
console.log(TAG, 'Live data feed failed');
}
);
},
function() {
console.log(TAG, 'Login failed');
}
);
}
function runApp() {
/* Implement application here */
}
</script>
</body>
</html>
git clone https://github.com/ipcortex/api-samples.git