您可以使用 XML POST 请求与 Kronos API 进行通信。
The WFC v5.0 Developer's Toolkit Programmer's Guide1 provides a general guide for communicating with the Kronos API in various languages. The first chapter covers the XML API, which is how all API requests will be sent.
登录请求
Kronos WFC 的标准 XML 登录请求。该请求必须在任何其他请求之前先发送。
<Kronos_WFC version="1.0">
<Request Object="System" Action="Logon" Username="ValidUsername" Password="ValidPassword"/>
</Kronos_WFC>
回复:
<Kronos_WFC version="1.0" TimeStamp="11/15/2017 3:35PM GMT-05:00">
<Response Status="Success" Timeout="1800" PersonKey="123456" Object="System" Username="ValidUsername" Action="Logon" PersonNumber="112233">
</Response>
</Kronos_WFC>
注销请求
此注销请求将结束您的活动 Kronos 会话。
<Kronos_WFC version="1.0">
<Request Object="System" Action="Logoff"/>
</Kronos_WFC>
付款期总请求
此请求加载员工的工资期总计12345
2017年10月20日至2017年10月27日期间。
<Kronos_WFC version="1.0">
<Request Action="Load">
<Timesheet>
<Employee>
<PersonIdentity PersonNumber="12345"/>
</Employee>
<Period>
<TimeFramePeriod PeriodDateSpan="10/20/2017 - 10/27/2017"/>
</Period>
</Timesheet>
</Request>
</Kronos_WFC>
Kronos API 标签的完整列表可以在劳动力计时开发工具包参考指南 (需要登录).
您发送 POST 请求的方法可能会因您的语言而异。但是,XML 请求格式和 API 入口点(<ServerName>/wfc/XmlService
) 应适用于所有语言。
以下是用于发送 Kronos 登录请求的 Python 3 脚本示例:
import requests
url = "http://localhost/wfc/XmlService"
headers = {'Content-Type': 'text/xml'}
data = """<Kronos_WFC version = "1.0">
<Request Object="System" Action="Logon" Username="SomeUsername" Password="SomePassword"/>
</Kronos_WFC>"""
# Login to Kronos and print response
session = requests.Session() # preserve login cookies across requests
response = session.post(url, data=data, headers=headers)
print(response.text)
WFC 开发人员工具包程序员指南的第 2 章包括在以下位置发送 XML 请求的示例:Java and 视觉基础。不过,我建议您研究特定于您所使用的任何语言的更新的 XML 或 HTTP 请求库。
有用的资源
-
Workforce Timekeeper v8.0.16 开发人员工具包参考指南 (需要登录)
- WFC v5.0 开发人员工具包程序员指南
-
Kronos 产品的文档和服务包 (需要登录)
- WFC-API.js - 用于向 WFC API 发送 XML 请求的 JavaScript
- TimeCardView - Kronos API 的开源 Web UI
- Kronos 社区论坛
脚注:
1: The quoted documentation was originally written for Kronos WFC 5.0 (API 1.0). While later versions should use the same API, I cannot guarantee accuracy for other versions. (See XML API version 6.3 to 8.0 upgrade)