短信¶
项目规则行动¶
Program Rule Actions
出站短信服务¶
预测变量
预测变量
Name, ShortName, Description, Generator Description
ValidationRule
ValidationRule
Name, Description, Instruction, Leftside expression, Rightside expression
国际化 { #webapi_i18n }
为了检索翻译字符串的键值对,您可以使用 i18n 资源。
/ api / 33 / i18n
端点位于 /api/i18n 并且请求格式是一个简单的 键值对数组:
网关响应码¶
请求必须是 POST 类型并使用 application/json 作为 内容类型。使用 curl 的示例,假设请求数据已保存 作为文件keys.json:
curl -d @keys.json "play.dhis2.org/demo/api/33/i18n" -X POST
-H "Content-Type: application/json" -u admin:district
| 结果将如下所示: | json { "access_denied":"Access denied", "uploading_data_notification":"Uploading locally stored data to the server" } | SMS | |---|---|---| | 短消息服务(SMS) { #webapi_sms } | 本节介绍用于发送和接收短文本的 SMS Web API 消息。 | Outbound SMS service | | Web API 支持使用 POST 方法发送外发 SMS。短信可以 发送到单个或多个目的地。一个或多个网关需要 在使用服务之前进行配置。如果出现以下情况,将不会发送短信 没有配置网关。它需要一组接收者和 JSON 格式的消息文本,如下所示。 | / api / sms / outbound | json { "message":"Sms Text", "recipients": [ "004712341234", "004712341235" ] } | | > Note
Recipients list will be partitioned if the size exceeds
MAX_ALLOWED_RECIPIENTSlimit of 200. | Web API 也支持查询参数版本,但 参数化 API 只能用于发送短信到单个 目的地。 | / api / sms / outbound?message = text&recipient = 004712341234 | | 可以使用GET资源提取出站邮件。 | GET / api / sms / outbound GET / api / sms / outbound?filter = status:eq:SENT GET / api / sms / outbound?filter = status:eq:SENT&fields = * | 可以使用DELETE资源删除出站邮件。 | | 删除/ api / sms / outbound / {uid} 删除/ api / sms / outbound?ids = uid1,uid2 | Gateway response codes | 网关可以使用以下响应代码进行响应。 | | Table: Gateway response codes | Response code | Response Message | | Detail Description | RESULT_CODE_0 | success | | Message has been sent successfully | RESULT_CODE_1 | scheduled | | Message has been scheduled successfully | RESULT_CODE_22 | internal fatal error | | Internal fatal error | RESULT_CODE_23 | authentication failure | | Authentication credentials are incorrect | 本节介绍用于发送和接收短文本的 SMS Web API 消息。 | data validation failed | | Parameters provided in request are incorrect | RESULT_CODE_25 | insufficient credits | | Credit is not enough to send message | RESULT_CODE_26 | upstream credits not available | | Upstream credits not available | RESULT_CODE_27 | exceeded your daily quota | | You have exceeded your daily quota | RESULT_CODE_40 | temporarily unavailable | | Service is temporarily down | RESULT_CODE_201 | maximum batch size exceeded | | Maximum batch size exceeded | RESULT_CODE_200 | success | | The request was successfully completed | RESULT_CODE_202 | accepted | | The message(s) will be processed | RESULT_CODE_207 | multi-status | | 向应用项目接口提交了多条信息,但并非所有信息的状态都相同 | RESULT_CODE_400 | bad request | | Validation failure (such as missing/invalid parameters or headers) | RESULT_CODE_401 | unauthorized |
入站短信服务¶
RESULT_CODE_402
payment required
Not enough credit to send message
RESULT_CODE_404
not found
Resource does not exist
RESULT_CODE_405
method not allowed
Http method is not support on the resource
用法
| 默认值 | Potential duplicate status | Parameter name |
|---|---|---|
| 技术性更强、对开发人员更友好的消息(目前尚未使用)。 | 具有以下要求: | RESULT_CODE_503 |
| service unavailable | 具有以下要求: | Inbound SMS service |
| Web API 支持使用 POST 收集传入的 SMS 消息 | ||
| 方法。路由到 DHIS2 Web API 的传入消息可以是 | ||
| 使用此 API 接收。 API 收集入站 SMS 消息和 | ||
| 根据短信内容(SMS | ||
| 命令)。下面给出了 JSON 格式的示例负载。文本, | ||
| 发起者、接收日期和发送日期是强制性参数。这 | ||
| 其余是可选的,但系统将使用这些默认值 | ||
| 参数。 | 具有以下要求: | ```json |
| { | ||
| "text": "sample text", | ||
| "originator": "004712341234", | ||
| "gatewayid": "unknown", | ||
| "receiveddate": "2016-05-01", | ||
| "sentdate":"2016-05-01", | ||
| "smsencoding": "1", | ||
| "smsstatus":"1" | ||
| } | ||
| ``` | ||
| 可以使用GET resourcef获取入站消息 | query | 可以使用DELETE资源删除入站邮件 |
网关服务管理¶
导入所有未解析的消息
POST /api/sms/入站/导入
Table: User query parameters
Parameter
类型
描述
message
串
This is mandatory parameter which carries the actual text message.
originator
串
This is mandatory parameter which shows by whom this message was actually sent from.
gateway
串
This is an optional parameter which gives gateway id. If not present default text "UNKNOWN" will be stored
网关配置¶
日期
Clickatell{ #clickatell }¶
Gateway service administration
散装¶
可以使用 GET 检索配置的不同网关的列表 方法。
SMPP网关¶
还可以使用特定网关类型检索配置 获取方法。
通用HTTP¶
可以使用 POST 添加新的网关配置。 POST api 需要类型请求参数,目前它的值可以有一个 http,bulksms,clickatell,smpp。第一个添加的网关将设置为默认值。一次只能默认一个网关。默认网关只能通过其 api 更改。如果删除了默认网关,则列表中的下一个网关将自动变为默认网关。
POST / api / 33 / gateways
可以通过提供如下所述的uid和网关配置来更新配置
| 默认值 | Potential duplicate status | Parameter name |
|---|---|---|
| displayColumnOrder | 具有以下要求: | 可以使用PUT方法设置默认网关。 |
| PUT /api/33/gateways/default/{uid} | 具有以下要求: | Web API 允许您创建和更新网关配置。对于每个 |
| 网关类型 JSON 有效负载中有不同的参数。 | ||
| 下面给出了每个网关的示例 JSON 有效负载。 POST 用于 | ||
| create 和 PUT 以更新配置。标头参数可用于 | ||
| GenericHttpGateway 将一个或多个参数作为 http 标头发送的情况。 | ||
| Clickatell | userDataStore 由用户、命名空间、键和关联的 | |
| 值。用户、命名空间和密钥的组合是唯一的。 | Bulksms | |
| ```json | ||
| { | ||
| "type": "bulksms", | ||
| "name": "bulkSMS", | ||
| "username": "bulkuser", | ||
| "password": "abc123" | ||
| } | ||
| 具有以下要求: |json | ||
| { | ||
| "type": "smpp", | ||
| "name": "smpp gateway2", | ||
| "systemId": "smppclient1", | ||
| "host": "localhost", | ||
| "systemType": "cp", | ||
| "numberPlanIndicator": "UNKNOWN", | ||
| "typeOfNumber": "UNKNOWN", | ||
| "bindType": "BIND_TX", | ||
| "port": 2775, | ||
| "password":"password", | ||
| "compressed": false | ||
| } | ||
| ``` | ||
| Generic HTTP | 具有以下要求: | 在通用的http网关中,可以添加任意数量的参数。 |
| Table: Generic SMS gateway parameters | userDataStore 由用户、命名空间、键和关联的 | |
| 值。用户、命名空间和密钥的组合是唯一的。 | 类型 | |
| 描述 | userDataStore 由用户、命名空间、键和关联的 | |
| 值。用户、命名空间和密钥的组合是唯一的。 | 串 | |
| 产生价值终点 { #webapi_generate_values } | 具有以下要求: | 串 |
| 日期时间 | 具有以下要求: | Boolean |
| Http POST nethod will be used by default. In order to change it and Http GET, user can set useGet flag to true. | userDataStore 由用户、命名空间、键和关联的 | |
| 值。用户、命名空间和密钥的组合是唯一的。 | 串 | |
| Content type specify what type of data is being sent. Supported types are APPLICATION_JSON, APPLICATION_XML, FORM_URL_ENCODED, TEXT_PLAIN | userDataStore 由用户、命名空间、键和关联的 | |
| 值。用户、命名空间和密钥的组合是唯一的。 | 串 |
Url template
header¶
Boolean
If parameter needs to be sent in Http headers
encode
Boolean
If parameter needs to be encoded
key
串
parameter key
价值
串
parameter value
短信命令类型¶
| Potential duplicate status | If parameter is confidential. This parameter will not be exposed through API |
|---|---|
| sendUrlParameters | 类型 |
If this flag is checked then urlTemplate can be appended with query parameters. This is usefull if gateway API only support HTTP GET. Sample urlTemplate looks like this "urlTemplate":"https://samplegateway.com/messages?apiKey={apiKey}&to={recipients},content={text},deliveryreport={dp}" | 如果配置保存成功则返回 HTTP.OK 否则 Error |
| 短信命令 { #webapi_sms_commands } | SMS 命令用于通过 SMS 收集数据。这些命令 |
| 属于特定的解析器类型。每个解析器都有不同的功能。 | |
| 可以使用GET检索命令列表。 | KEY_VALUE_PARSER |
| 可以使用GET检索一个特定的命令。 | GET /api/smsCommands/uid |
| 可以使用PUT更新一个特定的命令。 | PUT /api/smsCommands/uid |
Android的SMS命令类型¶
POST / api / smsCommands
| Potential duplicate status | If parameter is confidential. This parameter will not be exposed through API |
|---|---|
| SMS command types | 类型 |
| PERIOD_STRUCTURE | KEY_VALUE_PARSER |
| 用于汇总数据收集。 | ALERT_PARSER |
| 发送警报消息。 | 未注册_解析器 |
| 用于疾病监测病例报告。 | TRACKED_ENTITY_REGISTRATION_PARSER |
| 用于跟踪器实体注册。 | PROGRAM_STAGE_DATAENTRY_PARSER |