Ryan Posted October 11, 2010 Report Share Posted October 11, 2010 Hello, I would like to grab a list of current calls from pbxnsip. I don't care how I get it, even if I just have to read from an XML file or anything like that. I do have my CDR tied into MySQL, but I am not sure if the current calls get written to the database; maybe someone can clear that up. I will be using a PHP script to parse whatever info I can find, just fyi. Ryan Quote Link to comment Share on other sites More sharing options...
Vodia PBX Posted October 13, 2010 Report Share Posted October 13, 2010 Not an easy topic... The best way to do this is to build on CSTA. There are more proprietary interfaces (e.g. used by the WAC), but they are likely to change without notice and you dont want to change your code all the time. CSTA is standardized and gives you a documented API. Quote Link to comment Share on other sites More sharing options...
mattlandis Posted October 13, 2010 Report Share Posted October 13, 2010 oh! I expected WAC was built on CSTA. I was hoping... ;-) Matt Quote Link to comment Share on other sites More sharing options...
pbx support Posted October 14, 2010 Report Share Posted October 14, 2010 oh! I expected WAC was built on CSTA. I was hoping... ;-) Matt Currently, it is a mix of CSTA and proprietary. But we will clean it soon to use complete CSTA. Quote Link to comment Share on other sites More sharing options...
mattlandis Posted October 14, 2010 Report Share Posted October 14, 2010 Good move. Matt Quote Link to comment Share on other sites More sharing options...
Ryan Posted October 14, 2010 Author Report Share Posted October 14, 2010 What is CSTA? I googled it and found a bunch of odd information. Also, have you had any users just actually use cURL to conect directly as an admin, and look at the active call list? That seems to be an option too. Ryan Quote Link to comment Share on other sites More sharing options...
Ryan Posted October 15, 2010 Author Report Share Posted October 15, 2010 Seem like using cURL could be an issue as the page is ajax-updated and lags about a second before it checks, so the page is loaded, but the background is still going. Quote Link to comment Share on other sites More sharing options...
Vodia PBX Posted October 18, 2010 Report Share Posted October 18, 2010 Seem like using cURL could be an issue as the page is ajax-updated and lags about a second before it checks, so the page is loaded, but the background is still going. Right. There is this small blind spot when using AJAX! That's why multipart/mime (like MJPEG) would be better or CSTA. Anyway, what is there today is CSTA, "M-XML" might be an option later. Quote Link to comment Share on other sites More sharing options...
Ryan Posted October 19, 2010 Author Report Share Posted October 19, 2010 Right. There is this small blind spot when using AJAX! That's why multipart/mime (like MJPEG) would be better or CSTA. Anyway, what is there today is CSTA, "M-XML" might be an option later. Alright....so, any way you can point me in the right direction? Like a specific page to query or how I can try and use this CSTA with pbxnsip? I'm going to need this as since we're switching from Asterisk (which has active call list working), and I'll need a current active call list from pbxnsip. Quote Link to comment Share on other sites More sharing options...
Ryan Posted October 19, 2010 Author Report Share Posted October 19, 2010 I got it! I viewed the source of the "reg_calls.htm" page. It's making AJAX calls to the "ajax.htm" page. This page will return an XML response with the current calls. At least that's how it seems to be. Open the page like this (replace mydomain.com with your domain of course): http://mydomain.com/ajax.htm?action=call_list&domain=mydomain.com&token=whatever With no active calls, the response was: <ResultSet> <Token>74</Token> <Calls/> </ResultSet> When I made a phone call, I refreshed and got: <ResultSet> <Token>73</Token> - <Calls> - <Call> <Start>2010/10/19 11:54:43</Start> <From>Ryan G (107@mydomain.com)</From> <To>xxxxxxx@mydomain.com</To> <State>connected</State> <Index>7</Index> <Gain/> <Trunk>gxw</Trunk> </Call> </Calls> </ResultSet> And voila! (I replaced the number with xxxxxxx and domain with mydomain.com fyi). So obviously you could just Curl request this page and anytime you need it you have a current call list. Quote Link to comment Share on other sites More sharing options...
adampcpi Posted October 19, 2010 Report Share Posted October 19, 2010 I got it! I viewed the source of the "reg_calls.htm" page. It's making AJAX calls to the "ajax.htm" page. This page will return an XML response with the current calls. At least that's how it seems to be. Open the page like this (replace mydomain.com with your domain of course): http://mydomain.com/ajax.htm?action=call_list&domain=mydomain.com&token=whatever With no active calls, the response was: <ResultSet> <Token>74</Token> <Calls/> </ResultSet> When I made a phone call, I refreshed and got: <ResultSet> <Token>73</Token> - <Calls> - <Call> <Start>2010/10/19 11:54:43</Start> <From>Ryan G (107@mydomain.com)</From> <To>xxxxxxx@mydomain.com</To> <State>connected</State> <Index>7</Index> <Gain/> <Trunk>gxw</Trunk> </Call> </Calls> </ResultSet> And voila! (I replaced the number with xxxxxxx and domain with mydomain.com fyi). So obviously you could just Curl request this page and anytime you need it you have a current call list. I tested it here and that information may be handy... the authentication may be a problem though... in my brief testing you have to run it twice for it to work... once to login and then a 2nd time to get the information... Quote Link to comment Share on other sites More sharing options...
Ryan Posted October 19, 2010 Author Report Share Posted October 19, 2010 I tested it here and that information may be handy... the authentication may be a problem though... in my brief testing you have to run it twice for it to work... once to login and then a 2nd time to get the information... You are correct. But with Curl with PHP, you simply do 3 steps. Set your first curl URL to login.htm (set the login POST params), then hit the ajax.htm page, then logout.htm. Here is the code I wrote to make this work. I hope someone finds it useful. <?php /* * Pbxnsip Current Active Calls list * * Requires PHP 5+ because of simplexml functions * * Written by Ryan Gehrig * */ // // Set these to your server specifics // // Admin username/pass $pbx_user = 'admin'; $pbx_pass = 'pass123'; // Set server info $pbx_domain = 'http://mydomain.com'; // Main pbxnsip domain $pbx_phone_domain = 'ca.mydomain.com'; // Domain of your actual calls ################################################################################ ########################## // Ajax URL $pbx_ajax_url = $pbx_domain . '/ajax.htm?action=call_list&domain=' . $pbx_phone_domain . '&token=xxxxxxxx'; // Logout page $pbx_logout_url = $pbx_domain . '/logout.htm'; // Fields to pass for Login $postfields = "login_account=$pbx_user&login_password=$pbx_pass&login_type=auto&dom_link=dom_index.htm&usr_link=usr_index.htm"; // Setup cookies for login $cookies = 'cookies.txt'; if (!file_exists($cookies)) { $fp = fopen($cookies, 'w'); fwrite($fp, ''); fclose($fp); } // // Connect to pbxnsip interface // // Login first $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies); curl_setopt($ch, CURLOPT_URL, $pbx_domain); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); curl_exec($ch); // Get Ajax page curl_setopt($ch, CURLOPT_URL, $pbx_ajax_url); $content = curl_exec ($ch); // Logout curl_setopt($ch, CURLOPT_URL, $pbx_logout_url); curl_exec ($ch); // Close up curl_close($ch); ##################################################### // // Get XML response from Pbxnsip // $xml = simplexml_load_string($content); $ret_token = $xml->Token; $ret_calls = count($xml->Calls->Call); $call_start = $xml->Calls->Call->Start; $call_from = $xml->Calls->Call->From; $call_to = $xml->Calls->Call->To; $call_state = $xml->Calls->Call->State; $call_index = $xml->Calls->Call->Index; // Not sure what this is $call_gain = $xml->Calls->Call->Gain; // Not sure what this is either $call_trunk = $xml->Calls->Call->Trunk; ?> After this you could simply echo the variables, or use some kind of XML to PHP Array function (there are a million of them) and parse it that way. Ryan Quote Link to comment Share on other sites More sharing options...
adampcpi Posted October 20, 2010 Report Share Posted October 20, 2010 I tested it here and that information may be handy... the authentication may be a problem though... in my brief testing you have to run it twice for it to work... once to login and then a 2nd time to get the information... I am using VB so what I did was just pass the string twice but putting the admin username/password in the URL: http://admin:pass123@mydomain.com/ajax.htm...;token=whatever $call_index = $xml->Calls->Call->Index; // Not sure what this is This is the call identifier which now that I know I can pull this I am planning on building a front end for our receptions to force pages to stop paging... (ie you can pass that ID to http://admin:pass123@mydomani.com/dom_call...lete_call={ID}) I was looking for a way to do this without giving the receptionist full access to the PBX system. $call_gain = $xml->Calls->Call->Gain; // Not sure what this is either Mine never showed anything in Gain put typically means something do to with volume amplification... -Adam Quote Link to comment Share on other sites More sharing options...
Ryan Posted October 20, 2010 Author Report Share Posted October 20, 2010 I am using VB so what I did was just pass the string twice but putting the admin username/password in the URL: http://admin:pass123@mydomain.com/ajax.htm...;token=whatever $call_index = $xml->Calls->Call->Index; // Not sure what this is This is the call identifier which now that I know I can pull this I am planning on building a front end for our receptions to force pages to stop paging... (ie you can pass that ID to http://admin:pass123@mydomani.com/dom_call...lete_call={ID}) I was looking for a way to do this without giving the receptionist full access to the PBX system. $call_gain = $xml->Calls->Call->Gain; // Not sure what this is either Mine never showed anything in Gain put typically means something do to with volume amplification... -Adam I see. The index could be very useful then, for call barging, recording etc. I didn't even think of that. One other thing I wanted to note, is that when getting the XML data back and converting into an array, the XML response from pbxnsip isn't in a numbered format until there is more than 1 call connected/alerting. What that means is if you have 1 connected call, the response is like: Calls->Call->Start; Calls->Call->From; etc. But if there's more than 1 call coming in, it becomes numbered, like this: Calls->Call->0->Start; Calls->Call->0->From; Calls->Call->1->Start; Calls->Call->1->From; etc etc. So if you want a foreach loop or a for loop, you can only use it if there is more than 1 call. Otherwise you simply call the data like $xml['Calls']['Call']['Start'] etc. Quote Link to comment Share on other sites More sharing options...
hasan özgilik Posted December 12, 2011 Report Share Posted December 12, 2011 Also , how get other list like domain list , currently registered domain list , terminal list in dnd,terminal list in acd etc using this method. Or another methods. Quote Link to comment Share on other sites More sharing options...
hasan özgilik Posted December 22, 2011 Report Share Posted December 22, 2011 Hi, when I call this link http://10.200.2.123:8089/ajax.htm?action=call_list&domain=pbx.centricall.com&token=whatever without login to web page I get: <Call> <Start>12/22 16:58</Start> <From>05374435533</From> <To>70@10.200.2.123</To> <State>connected</State> <Index>14307</Index> <Gain/> <Trunk>CC GELEN</Trunk> </Call> But I login <Call> <Start>12/22 16:58</Start> <From>05374435533</From> <To>70 (6021)</To> <State>connected</State> <Index>14307</Index> <Gain/> <Trunk>CC GELEN</Trunk> </Call> Only Difference between "To" Tags <To>70@10.200.2.123</To> <To>70 (6021)</To> I have tried lots of thing. We could not keep sessions for login with .Net code (HttpWebRequest). Is there a way to get "<To>70 (6021)</To>" information without login. Quote Link to comment Share on other sites More sharing options...
hasan özgilik Posted January 3, 2012 Report Share Posted January 3, 2012 Call start date is coming without second information. Is there a setting for this. <Start>01/03 14:40</Start> <From>3285567</From> <To>4684700 (6041)</To> <State>connected</State> <Index>99821</Index> <Gain/> <Trunk>CC GELEN/GOZTEPE</Trunk> Quote Link to comment Share on other sites More sharing options...
pbx support Posted January 3, 2012 Report Share Posted January 3, 2012 Unfortunately, there is no setting for that. You get only HH:MM format. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.