Example 1. Retrieve property values
This is a sample program demonstrating how to retrieve property values using a string array of property names:
<script> var socket = null; var host = 'ws://192.168.200.10:18080/pbx/ws?tenant=test&login_user=1000&login_password=1000'; if('WebSocket' in window){ socket = new WebSocket(host); }else if('MozWebSocket' in window){ socket = new MozWebSocket(host); } socket.onmessage = function(event){ var response = JSON.parse(event.data); var properties = ["name", "desc", "language", "login.password", "admin"]; var request = '{"jsonrpc": "2.0", "method": "getExtensionProperties", "params": {"extension": "0001", "property_names":properties}, "id": 1}; var json_request = JSON.stringify(request); socket.send(json_request); switch(response['id']){ case '1': for(var i = 0; i < properties.length; i ++) console.log(properties[i] + ' = ' + response['result'][i]); break; } } </script>