cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1395
Views
0
Helpful
0
Replies

Script to "tell" the phone to call

TRSkarthis
Level 1
Level 1

Hello,

 

I've been trying to make a script in JS to make a phone call from pc using the cisco phone, found the script below in php, wich works and i've been trying to make it work in js with no sucess so far.

php script: https://github.com/samturner3/Cisco-IP-Phone-Dial-from-Web/blob/master/dialPush.php

 

Any help is appreciated,

thank you.

 

var net = require('net');

var number = "***";
var host = "**.*.***.***";
var data = '<CiscohostPhoneExecute><ExecuteItem Priority="0" URL="Dial:' + number + '"/></CiscohostPhoneExecute>';
var path = "/CGI/Execute";

var res = phonecall(host, data);

function phonecall(host, data, uid = "***", pwd = "***") {
    var aux = uid + ":" + pwd;
    var auth = Buffer.from(aux).toString('base64');

    console.log("encoded: " + auth);
    var xml = "XML=" + encodeURI(data);

    var http_request = "POST " + path + " HTTP/1.0\r\n";
    http_request += "Host: " + host + "\r\n";
    http_request += "Authorization: Basic " + auth + "\r\n";
    http_request += "Connection: close\r\n";
    http_request += "Content-Type: application/x-www-form-urlencoded\r\n";
    http_request += "Content-Length: " + xml.length + "\r\n";

    console.log(http_request)

    //var client = net.connect(80,host, function(){
    var client = net.createConnection(80, host, function () {
        console.log("ABC");
        //client.write(xml);
        client.end(xml);

        console.log("END")
    });
}
module.exports.phonecall = phonecall;

I've also tryed to use WebSockets. 

0 Replies 0