背景:第三方集成明源的移动产品,明源产品需要适配第三方的发送消息和更改状态api
开发原理图:
配置方法:
登录明源云移动产品企业后台,企业号及账号密码请咨询对应一线。
自定义发送消息API,开发指引:
请求post,为json字符串:
---------------------
{
"handleType": "sendmsg",
"msgInfo": "{'tenant_id':'dev22','openid':'mysoft56a9e904f2674374273046','appcode':'3022','biz_id':'chentltest','msgtype':'oa','content':{'body':{'title':'待归档','title_wzs':'待归档','content':'12345','form':[]},'message_url':'11&wakeMode=&11'}}",
"userInfo": "{'user_guid':'xxxxxx','user_name':'张三','user_code':'cs','mobile_tel':'','offcie_tel':'','home_tel':'','email':'','is_disabled':'0','is_mobile_user':null,'user_kind':'0','create_time':'2016-04-1114: 48: 09','dept_guid':'171ac9eb-a983-45d2-9603-925d2ffa961','user_name_pinyin':'zhangsan','user_pwd':'xxxxx','erp_ver':'','user_name_pinyin_h':'','is_combination_mobile':'0'}",
"paramInfo": "{'erpapiauth_paramname':'UserCode','erpapi_url':'','erpapi_username':'','erpapi_password':'','_header_option':{'appid':'20014','appsecret':'xxxxxx'}}",
"sendmsgApiurl":"http://my.test.com",
"thirdUserInfo":"{\"user_guid\":\"449c5ffe-a12d-e811-af4e-4437e6cc97d0\",\"user_code\":\"007\",\"user_name\":\"小米\"}"
}
------------------
说明:主要包含三部分:
msgInfo: 消息体,里面有biz_id,参数,对应mytaskwak表的wakeguid,目前消息分为三种消息类型,text,news和oa,不同的类型,消息体的属性也不一致,请根据msgtype属性来读取相关信息
text 类消息 { "biz_id":null, "tenant_id": "my596d69f915319", "appcode": "3022", "openid": "mysoft5d529fc9e51ca126155081", "msgtype": "text", "content": "{\"content\":\"你有一个待办事项,点击 查看详情\"}", "status": 1, "safe": null, "sendto": 80, "no_disturbing": 0, "traceId": "512056a7a4e64702e83db2cbc239308f9d32c7f9", "recv_time": "2019-09-06 11:52:57", "mns_messageid": "C9BDB4CA4C9F630D7FD11C4C8607C801" } news类消息 { "biz_id": null, "tenant_id": "my596d69f915319", "appcode": "3022", "openid": "mysoft5d529fc9e51ca126155081", "msgtype": "news", "content": "{\"articles\":[{\"title\":\"待办提醒\",\"description\":\"亲爱的主人,您今天的待办事项如下:\\r\\n即将签约的客户有 3 位,\\r\\n逾期未签约的客户有 2 位,\\r\\n逾期未交款的客户有 4 位;\\r\\n请您及时进行催办,加油哦~~\",\"url\":\"http:\\\/\\\/qy-ci.mysoft.com.cn\\\/sale-micro\\\/my56a9c966df069\\\/remind\\\/contract\\\/zygw?p_TaskWakeId=1&UserGuid=7A916792-56C5-11E5-A33B-00155D0AB842&TaskIdentifier=1&__from=erpapijc\",\"picurl\":\"http:\\\/\\\/img.taopic.com\\\/uploads\\\/allimg\\\/140326\\\/235113-1403260U22059.jpg\"}]}", "status": 1, "safe": null, "sendto": 80, "no_disturbing": 0, "traceId": "435a2669e83dddd1f77ca573b3b957f63067a17f", "recv_time": "2019-09-06 14:05:04", "mns_messageid": "C9BDB4CA4C9F61357FD91CC57DFE3A63" } OA类消息 { "biz_id": "200000880", "tenant_id": "my596d69f915319", "appcode": "3022", "openid": "mysoft5d529fc9e51ca126155081", "msgtype": "oa", "content": "{\"head\":{\"bgcolor\":\"33b5e5\",\"text\":\"头部标题\"},\"message_url\":\"https:\\\/\\\/www.baidu.com?__from=erpapijc\",\"body\":{\"title\":\"审批提醒880\",\"content\":\"消息内容\",\"author\":\"初良祥\",\"image\":\"https:\\\/\\\/oss-mytest.oss-cn-hangzhou.aliyuncs.com\\\/0000\\\/applogos\\\/89275627eb304471795da7a10f8e7ef6.jpg?x-oss-process=image\\\/bright,0\",\"form\":[{\"key\":\"姓名:\",\"value\":\"张三\"},{\"key\":\"年龄:\",\"value\":\"20\"}],\"file_count\":3,\"rich\":{\"num\":\"15.6\",\"unit\":\"元\"}}}", "status": 1, "safe": null, "sendto": 80, "no_disturbing": 0, "traceId": "e960bdc9924d3f33ae0be18b9770506f8f444ba4", "mark": "[{\"bgcolor\":\"0000FF\",\"text\":\"帅\"}]", "extra": "{\"biz_type\":0,\"open\":\"http:\\\/\\\/qy-ci.fdccloud.com\\\/workflow-micro\\\/my596d69f915319\\\/workflow\\\/process-list\\\/index?kindType=5\"}", "recv_time": "2019-09-06 11:33:47", "mns_messageid": "C9BDB4CA4C9F61357FBF1C3AFCF546C4" }
根据msgtype的值来判断消息类型,
text类消息,msgInfo['content']['content']为消息内容
news类消息,msgInfo['content']['articles'][0]['title']为标题,msgInfo['content']['articles'][0]['description']为内容,msgInfo['content']['articles'][0]['url']为跳转链接,msgInfo['content']['articles'][0]['picurl']为图片地址
oa类消息,msgInfo['content']['body']['title']为标题,msgInfo['content']['body']['content']为内容,msgInfo['content']['message_url']为跳转链接,msgInfo['content']['body']['image']为图片地址
userInfo:用户信息体,里面有usercode,userguid信息
paramInfo:自定义参数体,用户接口调用时使用。
thirdUserInfo:使用云助手的外部联系人的应用,在使用接口 管家集成的时候会把对应的外部联系人的账号信息发过去,如 给项目跟投发送消息,则会把对应的项目跟投的用户信息发过去
-----------
返回值格式,json字符串:
-----------------------------------------------------------------------
{"errorcode":"错误code,正确标识为:0,否则为失败","errormsg":"错误的信息,请一定要填写此处错误新,便于问题排查","needRetry":"1"}
needRetry:是否需要重试,返回值为“1”,会间隔2min中的重试,最多重试20次
示例:
------------------------------------------------------
{"errorcode":"0","errormsg":""}
自定义更新待办API,开发指引:
请求post,为json字符串:
---------------------
{"data":{ "handleType":"changestatuas", "msgInfo":"{\"tenant_id\":\"my573e6b5609e44\",\"biz_id\":\"biz123456\",\"sendto\":\"erpapi\",\"msgcontent\":{\"openid\":\"mysoft5d53c120cc423772690782\",\"app_code\":\"3022\",\"process_guid\":\"b5586c89-52f1-e811-8d8e-005056907212\",\"status\":0}}", "paramInfo":"{\"scret\":\"fusheng\"}", "sendmsgApiurl":""} }
返回值格式,json字符串:
-----------------------------------------------------------------------
{"errorcode":"错误code,正确标识为:0,否则为失败","errormsg":"错误的信息,请一定要填写此处错误新,便于问题排查","needRetry":"1"}
needRetry:是否需要重试,返回值为“1”,会间隔2min中的重试,最多重试20次 示例: {"errorcode":"0","errormsg":""}
查看日志:
备注
1、如果是mip接口请选择权限为OAuth 2.0
作者: 初良祥 日期: 2023-05-08