欢迎!这里是飞印API文档

飞印API文档描述、示例


打印接口回调

简要描述:

  • 如果商户在飞印公众号中设置了其回调地址,那么飞印平台在有特定事件发生时,会主动通过这个回调地址往第三方系统push事件通知。
  • 譬如:当商户名下所有的机器的消息打印完毕后,飞印平台会立即通过回调向商户的系统通知该打印完成事件。
  • 当商户名下的设备离线/上线/缺纸等情况发生时也会通知到第三方系统。

请求方式:

  • POST,JSON提交

异常重试策略:

  • 如果商户的系统没有响应(譬如在维护或网络异常),飞印平台会依次按照如下时间间隔(秒)共重试7次:1, 3, 6, 9, 12, 15, 18秒(一共64秒)

参数:

参数名 必选 类型 说明
msg_type string 回调的消息类型,主要有<br>msg_printed 消息打印回调<br> device_status 打印机状态变更回调
payload object 回调消息体,object格式视msg_type的值而定,详见下面说明
  • 当msg_type=msg_printed时,payload为下列对象
参数名 必选 类型 说明
device_no string 机器编号
msg_no string 商户在 [发送消息](https://www.showdoc.cc/home/page/index/page_id/82826059039914 "发送消息")时指定的关联id: msg_no 如果没有关联,飞印平台会自动生成一个uuid代替
print_time string 打印完成的时间,yyyy-MM-dd HH:mm:ss
secret string 签名,把device_no,msg_no, print_time和API_KEY 的值按顺序直接拼接起来,做MD5加密: md5(把device_no + msg_no + print_time + API_KEY)

请求示例

{
    &quot;msg_type&quot;:&quot;msg_printed&quot;,
    &quot;payload&quot;: {
        &quot;device_no&quot;: &quot;4600408123456789&quot;,
        &quot;print_time&quot;: &quot;2017-08-01 10:03:04&quot;,
        &quot;msg_no&quot;:&quot;some-thirdparty-id&quot;,
        &quot;secret&quot;: &quot;005eabe86be0b7de3cee8cfbffeff96a&quot;
    }
}
  • 当msg_type=device_status时,payload为下列对象
参数名 必选 类型 说明
device_no string 机器编号
online_status string 打印机在线运行状态,包括:<br> online 在线 <br> offline 离线 <br> overheat 打印头过热 <br> error 打印机系统故障
paper_status string 打印机纸张状态,包括:<br> normal 正常 <br> lack 缺纸
secret string 签名,把device_no,online_status, paper_status和API_KEY 的值按顺序直接拼接起来,做MD5加密: md5(把device_no + online_status + paper_status + API_KEY)

请求示例

{
    &quot;msg_type&quot;:&quot;device_status&quot;,
    &quot;payload&quot;: {
        &quot;device_no&quot;: &quot;4600408123456789&quot;,
        &quot;online_status&quot;: &quot;online&quot;,
        &quot;paper_status&quot;:&quot;normal&quot;,
        &quot;secret&quot;: &quot;1122abe86be0b7de3cee8cfbffef3344&quot;
    }
}

对于所有飞印平台发出的回调请求,飞印平台会预期得到第三方系统返回如下response,

{
    &quot;errcode&quot;: 0,
    &quot;errmsg&quot; : &quot;ok&quot;
}

返回参数说明

参数名 类型 说明
errcode number 返回状态,0为成功,非0表示第三方系统未能正确处理飞印发送过来的回调请求
errmsg string 错误说明,当errcode为0时为"ok",否则需要填写出错说明

页面列表

ITEM_HTML