להלן מדריך API של 1COM הכולל דוגמאות לכל פעולה
ניתן להתעדכן בפעולות חסרות גם במסמך זה
Proxyapi is the way to manage your PBX from external softwares. It allows easy access to calls, phone status and more. It allows also to create, delete and edit records, even if in a limited way.
Proxyapi can be used by each tenant using an API key generated in the Configuration/Settings page. Two kinds of keys can be generated, one allowing Read/Write access and one allowing only read-only operations.
The latest syntax for the operations can be retrieved by proxyapi itself, like for example: https://pbx6webserver.1com.co.il/pbx/proxyapi.php?key=FwLjNxpSyN8tNKmD&reqtype=HELP
Some usage example examples (please note the URL on the demo server is slightly different than on production servers - 1com/pbx):
If the amount of fields is too large and confusing, you can select the fields to return using a XML template defined in Configuration/Settings - XML Template and then use in the proxyapi request.
Let's name this XML template as Test_CSV
{row_loop}{$uniqueid},{$ID},{$te_id},{$realsrc},{$lastdst},{$start},{$duration},{$answer},{$direction},{$direction},{$disposition}
{/row_loop}
You can use as
https://pbx6webserver.1com.co.il/pbx/proxyapi.php?key=NLbP7GFNVRqu9SDm&reqtype=INFO&info=DIDS
This command returns a call id like:
Success|Originate successfully queued|15a4cfe6429054|
The call id can be used to retrieve the recording with
It will be contained in the "OriginateID" field in the cdr table
You can provide variables to the dial plan, by using the var parameter like:
%3D is the URL encoded equivalent of =
The variable will be available in the dial plan as "TENANTCODE-variable". In this example as DEMO-callid
https://pbx6webserver.1com.co.il/pbx/proxyapi.php?key=NLbP7GFNVRqu9SDm&reqtype=COUNTCALLS
https://pbx6webserver.1com.co.il/pbx/proxyapi.php?key=NLbP7GFNVRqu9SDm&reqtype=INFO&info=recording&id=srv02-1531779475.48&tenant=DEMO
Based on your browser settings, you can force the browser to play the recording using the "playrecording" info parameter
<?php
$phonebook['NAME']="Ross";
$phonebook['PHONE1']="3564732920";
$url = "https://pbx6webserver.1com.co.il/pbx/proxyapi.php?key=NLbP7GFNVRqu9SDm&reqtype=PHONEBOOK&subreqtype=add&phonebook=Default&tenant=DEMO";
$resource = curl_init();
curl_setopt($resource, CURLOPT_URL, $url);
curl_setopt($resource, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($resource, CURLOPT_VERBOSE, true);
curl_setopt($resource, CURLOPT_POSTFIELDS, "values=".urlencode(json_encode($phonebook)));
$data = curl_exec($resource);
curl_close($resource);
print_r($data);
?>
<?php
$postfields = array(
'filename' => '@protected/FAXtestPage.pdf'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://pbx6webserver.1com.co.il/pbx/proxyapi.php?key=NLbP7GFNVRqu9SDm&reqtype=FAX&action=send&number=99397654321&source_number=123412345&tenant=DEMO");
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$postResult = curl_exec($ch);
if (curl_errno($ch)) {
print curl_error($ch);
}
curl_close($ch);
Please note, when getting the CSV for a single tenant, the CSV format used is the tenant one, when getting the CSV for multiple tenants, the Admin format is used
It returns something like:
UniqueID|Type|Type ID|Value|Type Name|Value Name
srv02-1509806457.625|START|0|2017-11-04 15:41:01||
srv02-1509806457.625|CALLERID|0|Susan <1132555678>||
srv02-1509806457.625|VARIABLE|85|36985||
srv02-1509806457.625|VARIABLE|144|56896||
srv02-1509806457.625|QUEUE|281|||
srv02-1509806457.625|ANSWER|0|105-DEMO||
srv02-1509806457.625|HANGUP|0|||
Based on the xml format shown in the manual, it returns something like:
<?xml version="1.0">
<Result>
<Agent>105-DEMO</Agent>
<Status>NOT ACTIVE</Status>
<Queue>supportQ</Queue>
<ClientID>1234</MemberNumber>
<OrderNumber>11223344</MemberNumber>
<Caller>Manuel <7171345678></Caller>
<VoiceFile>3619</VoiceFile>
</Result>
Any ManageDB action requires an admin key
$config['cu_name']="Boss phone";
$config['cu_ct_id']=1;
$config['cu_param1']="3564732920";
$config['cu_param2']="INCOMINGDID";
$config['cu_param3']="30";
$url = "https://pbx6webserver.1com.co.il/pbx/proxyapi.php?key=NLbP7GFNVRqu9SDm&reqtype=MANAGEDB&action=add&object=custom&tenant=DEMO";
$resource = curl_init();
curl_setopt($resource, CURLOPT_URL, $url);
curl_setopt($resource, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($resource, CURLOPT_VERBOSE, true);
curl_setopt($resource, CURLOPT_POSTFIELDS, "jsondata=".urlencode(json_encode($config)));
$data = curl_exec($resource);
curl_close($resource);
print_r($data);
$config['cu_name']="Boss private phone";
$config['cu_id']=286;
$config['cu_param1']="0636287454";
$url = "https://pbx6webserver.1com.co.il/pbx/proxyapi.php?key=NLbP7GFNVRqu9SDm&reqtype=MANAGEDB&action=update&object=custom&tenant=DEMO&objectid=286";
$resource = curl_init();
curl_setopt($resource, CURLOPT_URL, $url);
curl_setopt($resource, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($resource, CURLOPT_VERBOSE, true);
curl_setopt($resource, CURLOPT_POSTFIELDS, "jsondata=".urlencode(json_encode($config)));
$data = curl_exec($resource);
curl_close($resource);
print_r($data);
$config['ph_name']="George Basement";
$config['ph_mac']='AA:BB:CC:DD:EE:FF:00:11';
$config['ph_pm_id']=5;
$url = "https://pbx6webserver.1com.co.il/pbx/proxyapi.php?key=NLbP7GFNVRqu9SDm&reqtype=MANAGEDB&action=add&object=phones&tenant=DEMO";
$resource = curl_init();
curl_setopt($resource, CURLOPT_URL, $url);
curl_setopt($resource, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($resource, CURLOPT_VERBOSE, true);
curl_setopt($resource, CURLOPT_POSTFIELDS, "jsondata=".urlencode(json_encode($config)));
$data = curl_exec($resource);
curl_close($resource);
print_r($data);
$config['ph_name']="George Lower Basement";
$url = "https://pbx6webserver.1com.co.il/pbx/proxyapi.php?key=NLbP7GFNVRqu9SDm&reqtype=MANAGEDB&action=update&object=phone&objectid=207&tenant=DEMO";
$resource = curl_init();
curl_setopt($resource, CURLOPT_URL, $url);
curl_setopt($resource, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($resource, CURLOPT_VERBOSE, true);
curl_setopt($resource, CURLOPT_POSTFIELDS, "jsondata=".urlencode(json_encode($config)));
$data = curl_exec($resource);
curl_close($resource);
print_r($data);
$config['me_name']="Beep";
$url = "https://pbx6webserver.1com.co.il/pbx/proxyapi.php?key=NLbP7GFNVRqu9SDm&reqtype=MANAGEDB&action=update&object=mediafile&objectid=10&tenant=DEMO";
$resource = curl_init();
curl_setopt($resource, CURLOPT_URL, $url);
curl_setopt($resource, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($resource, CURLOPT_VERBOSE, true);
curl_setopt($resource, CURLOPT_POSTFIELDS, "jsondata=".urlencode(json_encode($config)));
$data = curl_exec($resource);
curl_close($resource);
print_r($data);
<?php
$postfields = array(
'filename' => '@audio.wav'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://pbx6webserver.1com.co.il/pbx/proxyapi.php?key=NLbP7GFNVRqu9SDm&reqtype=MANAGEDB&object=MEDIAFILE&action=updatebinary&objectid=247&tenant=DEMO");
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$postResult = curl_exec($ch);
if (curl_errno($ch)) {
print curl_error($ch);
}
curl_close($ch);
<?php
$destinations=array('EXT-1701','EXT-1703','EXT-1705','CUSTOM-67');
$url = "https://pbx6webserver.1com.co.il/pbx/proxyapi.php?key=NLbP7GFNVRqu9SDm&reqtype=MANAGEDB&action=setextensions&object=huntlist&objectid=26&tenant=DEMO";
$resource = curl_init();
curl_setopt($resource, CURLOPT_URL, $url);
curl_setopt($resource, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($resource, CURLOPT_VERBOSE, true);
curl_setopt($resource, CURLOPT_POSTFIELDS, "jsondata=".urlencode(json_encode($destinations)));
$data = curl_exec($resource);
curl_close($resource);
print_r($data);
?>
<?php
$value['ex_callallowed']='none';
//$value['ex_callallowed']='all';
$url = "https://pbx6webserver.1com.co.il/pbx/proxyapi.php?key=NLbP7GFNVRqu9SDm&reqtype=MANAGEDB&action=update&object=extension&objectid=1695&tenant=DEMO";
$resource = curl_init();
curl_setopt($resource, CURLOPT_URL, $url);
curl_setopt($resource, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($resource, CURLOPT_VERBOSE, true);
curl_setopt($resource, CURLOPT_POSTFIELDS, "jsondata=".urlencode(json_encode($value)));
$data = curl_exec($resource);
curl_close($resource);
print_r($data);
?>
$config['ex_number']="1100";
$config['ex_name']='Test extension';
$config['ex_tech']='SIP';
$config['secret']='hackmeifyoucan';
$url = "https://DEMO.1com.com/1com/proxyapi.php?key=NLbP7GFNVRqu9SDm&reqtype=MANAGEDB&action=add&object=extension&tenant=DEMO";
$resource = curl_init();
curl_setopt($resource, CURLOPT_URL, $url);
curl_setopt($resource, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($resource, CURLOPT_VERBOSE, true);
curl_setopt($resource, CURLOPT_POSTFIELDS, "jsondata=".urlencode(json_encode($config)));
$data = curl_exec($resource);
curl_close($resource);
print_r($data);
<?php
$config['cr_number']="887";
$config['cr_name']='Test conference';
$config['pin']='5678';
$url = "https://pbx6webserver.1com.co.il/pbx/proxyapi.php?key=NLbP7GFNVRqu9SDm&reqtype=MANAGEDB&action=add&object=conference&tenant=DEMO";
$resource = curl_init();
curl_setopt($resource, CURLOPT_URL, $url);
curl_setopt($resource, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($resource, CURLOPT_VERBOSE, true);
curl_setopt($resource, CURLOPT_POSTFIELDS, "jsondata=".urlencode(json_encode($config)));
$data = curl_exec($resource);
curl_close($resource);
print_r($data);
?>
<?php
$config['rp_name']='Only National calls';
$url = "https://DEMO.1com.com/1com/proxyapi.php?key=NLbP7GFNVRqu9SDm&reqtype=MANAGEDB&action=update&object=routingprofile&objectid=275"; $resource = curl_init(); curl_setopt($resource, CURLOPT_URL, $url); curl_setopt($resource, CURLOPT_RETURNTRANSFER, 1); curl_setopt($resource, CURLOPT_VERBOSE, true); curl_setopt($resource, CURLOPT_POSTFIELDS, "jsondata=".urlencode(json_encode($config))); $data = curl_exec($resource); curl_close($resource);
print_r($data); ?>
<?php
$config['di_comment']='Test DID';
$config['di_recording']='yes';
$url = "https://pbx6webserver.1com.co.il/pbx/proxyapi.php?key=NLbP7GFNVRqu9SDm&reqtype=MANAGEDB&action=update&object=did&objectid=27699";
$resource = curl_init();
curl_setopt($resource, CURLOPT_URL, $url);
curl_setopt($resource, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($resource, CURLOPT_VERBOSE, true);
curl_setopt($resource, CURLOPT_POSTFIELDS, "jsondata=".urlencode(json_encode($config)));
$data = curl_exec($resource);
curl_close($resource);
print_r($data);
?>
<?php
$config[]='PLAYBACK-60';
$config[]='EXT-29379';
$url = "https://pbx6webserver.1com.co.il/pbx/proxyapi.php?key=NLbP7GFNVRqu9SDm&reqtype=MANAGEDB&object=DESTINATION&action=replace&typesrc=DID&typeidsrc=27699&tenant=DEMO";
$resource = curl_init();
curl_setopt($resource, CURLOPT_URL, $url);
curl_setopt($resource, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($resource, CURLOPT_VERBOSE, true);
curl_setopt($resource, CURLOPT_POSTFIELDS, "jsondata=".urlencode(json_encode($config)));
$data = curl_exec($resource);
curl_close($resource);
print_r($data);
?>
You can use all these tags, with the id of the object
EXT - Dial an extension
SMS - Send a SMS to an extension
PLAYBACK - Play a media file
RERECORD - Rerecord a media file
CLEARRECORDING - Clear the media from a media file
RERECORDSILENT - Rerecord a media file without playing an intro
CONDITION - Follow to a condition
VOICMEAIL - Call a voicemail
IVR - Call an IVR
DISA - Call a DISA
PAGING - Call a Paging group
HUNTLIST - Call a Huntlist
FLOW - Call a Flow
PARK - Park the call
SPECIAL - Execute a special destination (check the sp_specials table for the id)
MEETME - Join a conference
QUEUE - Dial a Queue
RESETQUEUESTATS - Reset the stats for a Queue
STARTCAMPAIGN - Start a campaign
REDIALNOTANSWEREDCAMPAIGN - Redial the calls not answered for a campaign
STOPCAMPAIGN - Stop a campaign
PAUSECAMPAIGN - Pause a campaign
PAUSECAMPAIGN - Unpause a campaign
REMOVEFROMCAMPAIGN - Remove called number from campaign
REMOVECALLERFROMCAMPAIGN - Remove caller number from campaign
ADDLATESTDIALEDOUTTOCAMPAIGN - Add latest dialed out number to campaign
ADDLATESTDIALEDINTOCAMPAIGN - Add latest dialed in number to campaign
ADDTODNCLIST - Add called number to Do Not Call list
LOGINQUEUE - Login caller to Queue
TOGGLELOGINQUEUE - Toggle Login/Logout caller to Queue
LOGINADQUEUE - Login caller to Queue
TOGGLELOGINADQUEUE - Toggle Login/Logout caller to Queue
TOGGLEPAUSEQUEUE - Toggle Pause/Unpause caller to Queue
LOGOUTALLAGENTSFROMQUEUE - Logout all agents from Queue
LOGOUTQUEUE - Logout caller from Queue
PAUSEQUEUE - Pause caller from Queue
UNPAUSEQUEUE - Unpause caller from Queue
PAUSEALLAGENTSINQUEUE - Pause all agents in Queue
UNPAUSEALLAGENTSINQUEUE - Unpause all agents in Queue
CUSTOM - Use a custom destination
PHONEBOOK - Route by Phone Book using regex
EXACTPHONEBOOK - Route by Phone Book not using regex
SETUNCONDITIONALDID - Set unconditional forwarding for a DID
ENABLEUNCONDITIONALDID - Enable the unconditional forwarding for a DID
DISABLEUNCONDITIONALDID - Disable the unconditional forwarding for a DID
TOGGLEUNCONDITIONALDID - Toggle the unconditional forwarding for a DID
CLIDNAMEBYPHONEBOOK - Set Caller ID Name by Phone Book
CALLERIDMOD - Alter Caller ID based on rule
MUSICONHOLD - Set Music On Hold to
RINGMUSICONHOLD - Ring extension using Music On Hold
RESPONSEPATH - Start Response Path
SAMENUMBERVM - Voicemail same number
You can assign the destination for a condition (true) using the URL
or condition (false) using the URL
For an IVR, you can assign the destination for a press 1 using the URL
Take in mind, the iv_me_id field is not used and the media files are stored in the destination table
Use the Destination call to replace values
This will give you the details of the condition, but in case for example of WEEKTIME condition or CALENDAR condition, you need to get the extended info like:
<?php
$config[0]['param1']='1';
$config[0]['param2']='8:00';
$config[0]['param3']='13:00';
$config[1]['param1']='1';
$config[1]['param2']='15:00';
$config[1]['param3']='19:00';
$config[2]['param1']='2';
$config[2]['param2']='8:00';
$config[2]['param3']='13:00';
$config[3]['param1']='2';
$config[3]['param2']='15:00';
$config[3]['param3']='19:00';
$url = "https://pbx6webserver.1com.co.il/pbx/proxyapi.php?key=NLbP7GFNVRqu9SDm&reqtype=MANAGEDB&object=CONDITION&action=replaceextendedinfos&objectid=20&tenant=DEMO";
$resource = curl_init();
curl_setopt($resource, CURLOPT_URL, $url);
curl_setopt($resource, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($resource, CURLOPT_VERBOSE, true);
curl_setopt($resource, CURLOPT_POSTFIELDS, "jsondata=".urlencode(json_encode($config)));
$data = curl_exec($resource);
curl_close($resource);
print_r($data);
?>