Connect. Communicate. Collaborate. Securely.

Home » Developer Zone » API/SDK Writers » Operator API
  •  
nhoague

Messages: 853
Karma: 18
Send a private message to this user
I'm tasked with building a PHP script that could run via cron that could display call statistics / extension in Operator.

How can I:

a) retrieve all call history in rows. After this I could run a simple MySQL INSERT into the DB
b) Clear the call history after every run of the import?

I plan on using the popular PHP graphing tool, http://www.ebrueggeman.com/phpgraphlib or http://jpgraph.net/ to display the returned data, then send it via html email every am to my customer. This graph would need to show number of calls / call duration per extension.

If this has already been done, or if you have ideas, I'd love to hear them! I'll even throw this out there ... This job could be for hire.

Thanks.
  •  
Miroslav Osladil (Kerio)

Messages: 188

Karma: 27
Send a private message to this user
Hi Nick,

there's an existing example getCallHistory.php for this purpose. Just edit the variable $limit. By omitting the $start and $limit you should get all the history.

For deleting the call history, you can use following code:
$api->sendRequest('CallHistory.clear');


Best regards,

[Updated on: Tue, 25 February 2014 08:54]


Miroslav Osladil
Senior Developer
Kerio Technologies

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

Messages: 853
Karma: 18
Send a private message to this user
Hey there, so far so good!

I still have two questions:

1) How do I know what fields / columnName(s) are available in the params array? i.e. timestamp, or TEL_NUM, where do those come from?

$paramsHistory = array(
"query" => array(
"orderBy" => array(array(
"columnName" => "timestamp",
"direction" => "Desc"
)),
"start" => 0,
"limit" => $limit
)
);
2) How can I get a list of all the extensions, usernames, and email addresses? I see I can get the extension description from the list of the dial plan, but the customer I am building this for literally has 400 items in the dial plan, and that just takes too long to parse.

Thanks!
  •  
Miroslav Osladil (Kerio)

Messages: 188

Karma: 27
Send a private message to this user
1) Only by asking or sniffing Web Administration. The available fields are:
long GUID;
string FROM_NUM;
string FROM_NAME;
KTS_ExtensionType FROM_TYPE;
string TO_NUM;
KTS_ExtensionType TO_TYPE;
KTS_CallHistoryStatus STATUS;
long TIMESTAMP;
long ANSWERED_DURATION; - time since the call has been answered
long CALL_DURATION; - total time

The constants are:
KTS_ExtensionType {
	KTS_ExtensionTypeUnknown,
	KTS_ExtensionTypeLine,
	KTS_ExtensionTypeInterface,
	KTS_ExtensionTypeOutboundRoute,
	KTS_ExtensionTypeConference,
	KTS_ExtensionTypeCallQueue,
	KTS_ExtensionTypeIvr,
	KTS_ExtensionTypeVoicemail,
	KTS_ExtensionTypeEmergencyNumber,
	KTS_ExtensionTypeRingGroup,
	KTS_ExtensionTypeEchoService,
	KTS_ExtensionTypeMusicService,
	KTS_ExtensionTypeDialByExtService,
	KTS_ExtensionTypeDialByNameService,
	KTS_ExtensionTypeCurrentTimeService,
	KTS_ExtensionTypeRecordAudioService,
	KTS_ExtensionTypeCallPickupService,
	KTS_ExtensionTypeDirectedCallPickupService,
	KTS_ExtensionTypeSpeedDial,
	KTS_ExtensionTypeCallParkingService,
	KTS_ExtensionTypeLineGroup,
	KTS_ExtensionTypeFaxReceiveService,
	KTS_ExtensionTypePagingGroup,
	KTS_ExtensionTypePagingService,
	KTS_ExtensionTypeVoicemailWithLogin,
	KTS_ExtensionTypeSpyService
}

KTS_CallHistoryStatus {
	KTS_CallHistoryStatusUnknown,
	KTS_CallHistoryStatusFailed,
	KTS_CallHistoryStatusBusy,
	KTS_CallHistoryStatusNoAnswer,
	KTS_CallHistoryStatusAnswered,
	KTS_CallHistoryStatusForbidden,
	KTS_CallHistoryStatusVoicemail,
	KTS_CallHistoryStatusFollowme
}

2) Try something like
$params = array(
	"query" => array(
		"orderBy" => array(array(
			"columnName" => "USERNAME",
			"direction" => "Asc"
		)),
		"start" => 0,
		"limit" => -1
	)
);
$response = $api->sendRequest('Users.get', $params);

Miroslav Osladil
Senior Developer
Kerio Technologies

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

Messages: 853
Karma: 18
Send a private message to this user
Awesome, the username piece works perfectly as I was hoping!

But see, in my opinion, the API is hard to understand, because how did you know to use the username for a column?
  •  
Miroslav Osladil (Kerio)

Messages: 188

Karma: 27
Send a private message to this user
You're right. It's a blackbox a little bit because Kerio Operator's API is not officially supported and you have no documentation of all the available API methods and params.

Miroslav Osladil
Senior Developer
Kerio Technologies

The views I express are my own and do not necessarily reflect the views of Kerio Technologies.
  •  
Miroslav Osladil (Kerio)

Messages: 188

Karma: 27
Send a private message to this user
Anyway, we love to help you! So don't worry. Wink

Miroslav Osladil
Senior Developer
Kerio Technologies

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

Messages: 853
Karma: 18
Send a private message to this user
200% Appreciated! You guys rock. Smile
Previous Topic: BLF application
Next Topic: CalDAV/CardDAV Connector with Kerio-Outlook-Connector
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: Fri Oct 20 03:29:41 CEST 2017

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