Connect. Communicate. Collaborate. Securely.

Home » Kerio User Forums » Kerio Operator » Can Operator dial a number from the API? (Number dialing for paging purposes)
  •  
2the Maxx Technology

Messages: 15

Karma: 0
Send a private message to this user
Hi,

Is it possible to let Operator dial a number without using a telephone? I.e. for calling a pager. This requires only a telephone number followed by a set of characters.

Cheers,
Ron
  •  
lkacian

Messages: 74

Karma: 5
Send a private message to this user
Yes this is important question for me too. I need this feature for integration with Zabbix .
Very very interesting thing.

Lubor Kacian
FONET Slovakia
  •  
2the Maxx Technology

Messages: 15

Karma: 0
Send a private message to this user
lkacian wrote on Thu, 08 December 2011 08:23
Yes this is important question for me too. I need this feature for integration with Zabbix .
Very very interesting thing.


Yep, offers many features indeed Cool
It is also possible via a workaround, but if the function is available via the API it is much easier.
  •  
lkacian

Messages: 74

Karma: 5
Send a private message to this user
But there is no functional workaround Sad
It seems that there is very modified asterisk.
CLI did't help me.

Lubor Kacian
FONET Slovakia
  •  
Vladimir Toncar (Kerio)

Messages: 1696
Karma: 39
Send a private message to this user
Hi,

You may dial using the same API that Operator's MyPhone interface uses. This is still not a public API as it is a subject to changes between versions but I can share an example script.

The attached bash script works for Operator 1.1.X.

The script is invoked as follows:

./dial <operator-server-address> <user-name> <password> <number-to-dial>

Some of the commands are a bit cryptic, so here's what the script does:

* It posts a login request and saves the authentication cookie in a file called cookie.txt
* It asks for a list of user's extensions and saves them in a file result.txt
* It parses result.txt to obtain the GUID of the first extension
* It dials from the extension to the given phone number

The API in Operator 1.2 is slightly different and I will post the modified script soon.

Vladimir

  • Attachment: dial
    (Size: 1.25KB, Downloaded 595 times)
  •  
2the Maxx Technology

Messages: 15

Karma: 0
Send a private message to this user
Vladimir,

Thx for the script and the info.
Keep you posted.

Regards,

Ron
  •  
Miroslav Osladil (Kerio)

Messages: 188

Karma: 27
Send a private message to this user
Hello,

in case you are still interested in API development, I would recommend to check out Kerio Developer Zone which contains some examples and sample applications using the Kerio APIs Client Library for PHP. Main target is Kerio Connect but with a small piece of work you will be able to communicate also with your Kerio Operator easily in PHP. 

Functionality against Kerio Operator might not be fully verified, documented, or even supported. This API is in progress, might change in the future. 

There are no plans yet to publish public API for Kerio Operator.

Best regards,

Miroslav Osladil
Senior Developer
Kerio Technologies

The views I express are my own and do not necessarily reflect the views of Kerio Technologies.
  •  
ravelord

Messages: 16
Karma: 0
Send a private message to this user
Hello all,

The dial script Vlad posted didn't work anymore for 1.2.X because of API changes. I reworked the original, added and changed a few things. Enjoy!

#!/bin/bash

if [ $# -ne 4 ]; then
  echo "usage: $0 <IP> <username> <password> <dialToNumber>"
  exit 1
fi

IP="$1"
USERNAME="$2"
PASSWORD="$3"
DIAL_TO="$4"
WGET=/usr/bin/wget
TIMESTAMP=$(date)

COOKIE=~/cookie.txt
#login
echo "Login into MyPhone..."
$WGET -q -t 1 -O - https://${IP}/myphone/dologin.php --no-check-certificate --keep-session-cookies --post-data "kerio_username=${USERNAME}&kerio_password=${PASSWORD}" --save-cookies ${COOKIE} >/dev/null

#get token from cookie
X_TOKEN=`grep TOKEN_OPERATOR_MYPHONE ${COOKIE} | awk '{print $7}'`

echo "Get all user's extensions..."
RESULT=~/result.txt
GUID=""
$WGET -q -t 1 -O - https://${IP}/myphone/api/jsonrpc/ --no-check-certificate --post-data "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"UserSettings.get\",\"params\":{}}" --load-cookies ${COOKIE} --header="X-Token: ${X_TOKEN}" > $RESULT

# get GUID of the first extension from array EXTENSIONS
GUID=$(sed 's|.*"EXTENSIONS":\[{"GUID":\([0-9]*\),.*|\1|' <$RESULT)

#echo $GUID
# wget -q -O - https://${IP}/myphone/api/jsonrpc/ --no-check-certificate --post-data "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"UserPhone.dial\",\"params\":{\"extensionGuid\":${GUID},\"toNum\":\"${DIAL_TO}\"}}" --load-cookies ${COOKIE} --header="X-Token: ${X_TOKEN}" > /dev/null

$WGET -q -t 1 -O - https://${IP}/myphone/api/jsonrpc/ --no-check-certificate --post-data "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"UserPhone.dial\",\"params\":{\"extensionGuid\":${GUID},\"toNum\":\"${DIAL_TO}\",\"sipUsername\":\"${USERNAME}\"}}" --load-cookies ${COOKIE} --header="X-Token: ${X_TOKEN}" > /dev/null

## clean & exit
rm -f cookie.txt result.txt

echo "$TIMESTAMP - $USERNAME - $4">>dial.log

[Updated on: Thu, 19 April 2012 20:35]

  •  
JNSoftware

Messages: 3
Karma: 0
Send a private message to this user
Does this script still work for Operator 2.x? If not, is there an updated version of this script for Operator 2.x? We've looked at the developer zone and don't see any information on the Operator UserPhone.dial method. Any additional information would be greatly appreciated.

Thanks,
Jon
  •  
JNSoftware

Messages: 3
Karma: 0
Send a private message to this user
To clarify, we are having problems with this script & Operator 2.x. If we use:
$WGET -q -t 1 -O - https ://${IP}/myphone/api/jsonrpc/ --no-check-certificate --post-data "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"UserPhone.dial\",\"params\":{\"extensionGuid\":${GUID},\"toNum\":\"${DIAL_TO}\",\"sipUsername\":\"${USERNAME}\"}}" --load-cookies ${COOKIE} --header="X-Token: ${X_TOKEN}"

We get the following response:
{"jsonrpc":"2.0","id":1,"error":{"code":-32602,"message":"Invalid count of input parameters. Expected %1, %2 given.","data":{"messageParameters":{"positionalParameters":[2,3],"plurality":1}}}}

If we remove the sipUsername parameter:

$WGET -q -t 1 -O - https ://${IP}/myphone/api/jsonrpc/ --no-check-certificate --post-data "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"UserPhone.dial\",\"params\":{\"extensionGuid\":${GUID},\"toNum\":\"${DIAL_TO}\"}}" --load-cookies ${COOKIE} --header="X-Token: ${X_TOKEN}"

We get:
{"jsonrpc":"2.0","id":1,"error":{"code":1000,"message":"Dialing failed.","data":{"messageParameters":{"positionalParameters":[],"plurality":1}}}}


Jon

(Note: the code above contains intentional spaces in the URLs to allow us to post the code -- the board prohibits us from posting URLs until we've posted more times.)
  •  
Miroslav Osladil (Kerio)

Messages: 188

Karma: 27
Send a private message to this user
Hello API fans!

I am sorry we cannot share any documentation with you at the moment, the API in Kerio Operator is not yet officially supported. That's why you have not found any information about API change on our Developer Zone page. But please, stay tuned!

From technical point of view the reason why things have changed is that Kerio Operator now supports multiple lines (SIP registrations).

Anyway, with a small effort you can use Kerio APIs Client Library for PHP and run this code easily. I believe that even most of you are sysadmins and would prefer short shell code, this is simple too.

try {
    $dialTo = '+14084964500';

    /* Login */
    $api->setComponentMyphone();
    $session = $api->login($hostname, $username, $password);

    /* Get my settings, it contains my extensions list, use the proper one */ 
    $mySettings = $api->sendRequest('UserSettings.get');
    $myExt = $mySettings['lines'][0]['guid'];
    
    /* Dial a number */
    $params = array(
    	'extensionGuid' => $myExt,
    	'toNum' => $dialTo
    );
    $api->sendRequest('UserPhone.dial', $params);
}
catch (KerioApiException $error) {
    /* Catch possible errors */
    print $error->getMessage();
}


If you feel this is something you would give a try, use the file attached bellow.

Please note, that you still need to download the Kerio APIs Client Library for PHP. From that bundle, the src folder is enough as described in step by step tutorial.

Second note, choose the requested extension you want to dial from. See the $mySettings['lines'][1]['guid']. It's an array.

As usual, feel free to send me a reply with any help or have any questions!

Cheers,

M.

  • Attachment: dial.php
    (Size: 1.30KB, Downloaded 228 times)

Miroslav Osladil
Senior Developer
Kerio Technologies

The views I express are my own and do not necessarily reflect the views of Kerio Technologies.
  •  
JNSoftware

Messages: 3
Karma: 0
Send a private message to this user
This was helpful, thank you.

Jon
Previous Topic: Logo on 79XX
Next Topic: Dialing out
Goto Forum:
  


Disclaimer:
Kerio discussion forums are intended for open communication between forum members and may contain information and material posted by members which may be useful in learning about Kerio products. The discussion forums are not intended to provide technical support for any specific product. Any information implied or expressed in the discussion forums is that of the posting member. Kerio is in no way responsible for the information posted in the forums, or its accuracy. Kerio employees may participate in the discussions, but their postings do not represent an offical position of the company on any issues raised or discussed. Kerio reserves the right to monitor and maintain the forums to promote free and accurate exchange of information.

Current Time: Tue Oct 17 01:59:18 CEST 2017

Total time taken to generate the page: 0.00546 seconds
.:: Contact :: Home ::.
Powered by: FUDforum 3.0.4.