微信营销平台对外接口
root upravil tuto stránku před 4 roky

欢迎使用 Wiki! 测试环境url前缀:

            192.168.50.32:13001

正式环境url前缀:

            内网测试正式环境 192.168.50.32:13000,正式环境  mem.360lj.com:13000

说明:所有接口都必须先获取token 以header参数传入才能调用 统一 x_www-form-urlencoded 格式提交参数 返回结果 success 1代表成功 0代表失败

1,获取访问token

post请求 http://192.168.50.32:13001/oauth2/ums/oauth2/accessToken

参数

grant_type client_credentials 公司应用调用接口统一 用客户端模式

autoRefresh true 是否自动刷新 此参数为true 生成的token会默认从缓存取过期会自动更新

applicationKey wechatcp 后台管理应用key

client_id B966BFB4-493C-441A-BF02-8E3750644DE8 客户端id

client_secret MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDL9NmMe2imMfzfQ54ol+v+qdQ0By9F8j+a1Ub3wdqKYhsky44EOkMFrb+o0QGz1pCUB59WIch8HpFvZ8DgmP1GfLGgTfK4TYZIzj5a+6jXeIRE4Kp0nEWOPf89nG0ktjl3Z4H2PdlDRNBXGF/xqbj3NjhoFrQAwuz9Lj10n2YBCwIDAQAB 秘钥(rsa公钥)

其他接口的header参数: Sso-Token eyJraWQiOiIiLCJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhcHBsaWNhdGlvbktleSI6IndlY2hhdGNwIiwiaXNzIjoiY21zIiwidXNlck5hbWUiOiJCOTY2QkZCNC00OTNDLTQ0MUEtQkYwMi04RTM3NTA2NDRERTgiLCJncmFudFR5cGUiOiJjbGllbnRDcmVkZW50aWFscyIsImV4cCI6MTU5MDk4MDk4OSwiaWF0IjoxNTkwOTczNzg5fQ.na73QWzgkY1nhaI6R9xD644jBSv_jLnFIqiFaRTsMqwco5D-pNai16-8oZAPBJvZ-FvRSxcv22xb5a4dXV4pNcwcrZJDP4hRdxdz7CsFzkraOaYuTs1Kns1UrN--uuRkP0X0xoZu9_K5FFRyNH6C5GtTKPoJJVFfCXDUvxDDghI 从token中获取 返回: success 1代表成功 0代表失败

{
    "success": 1,
    "messageCode": 200,
    "message": "操作成功!",
    "result": {
        "access_token": "eyJraWQiOiIiLCJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhcHBsaWNhdGlvbktleSI6IndlY2hhdGNwIiwiaXNzIjoiY21zIiwidXNlck5hbWUiOiJCOTY2QkZCNC00OTNDLTQ0MUEtQkYwMi04RTM3NTA2NDRERTgiLCJncmFudFR5cGUiOiJjbGllbnRDcmVkZW50aWFscyIsImV4cCI6MTU5MDk5MDI0NCwiaWF0IjoxNTkwOTgzMDQ0fQ.NDmrGhZgZipNL2pvLDLECKQTrsa455gnIoPF-jxZpIrAX01UbqnRW0uVY0uaaeaXz0ueZC00cDLi8tl1_5DH8chAEQbThsysZZ7nbjQlBDp_r06vCnUM_a8k_iZMbYbtRFvlUqoapAvggUnCjbDJRXAPpQyjxZt74g69YyZmEvE",
        "expires_in": "7200000"
    },
    "items": null,
    "totalCount": 0
}

2,添加粉丝,获取粉丝 ,认证重定向

添加粉丝

put请求 http://192.168.50.32:13001/mpwechat/wx/api/fans/addFans

参数

header:

Sso-Token eyJraWQiOiIiLCJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhcHBsaWNhdGlvbktleSI6IndlY2hhdGNwIiwiaXNzIjoiY21zIiwidXNlck5hbWUiOiJCOTY2QkZCNC00OTNDLTQ0MUEtQkYwMi04RTM3NTA2NDRERTgiLCJncmFudFR5cGUiOiJjbGllbnRDcmVkZW50aWFscyIsImV4cCI6MTU5MDk4MDk4OSwiaWF0IjoxNTkwOTczNzg5fQ.na73QWzgkY1nhaI6R9xD644jBSv_jLnFIqiFaRTsMqwco5D-pNai16-8oZAPBJvZ-FvRSxcv22xb5a4dXV4pNcwcrZJDP4hRdxdz7CsFzkraOaYuTs1Kns1UrN--uuRkP0X0xoZu9_K5FFRyNH6C5GtTKPoJJVFfCXDUvxDDghI

appId wx32817247717e7333

fans

[
  {
    "openId": "oIXH1t-sGaDdgpTWGsMPgqmKwWrQ",
    "subscribe": 1,
    "nickname": "成功",
    "sex": 1,
    "sexDesc": 0,
    "city": "guangzhou",
    "country": "china",
    "province": "guangdong",
    "language": "zh_CN",
    "headImgUrl": "http://thirdwx.qlogo.cn/mmopen/dWYcndbpDnaX98dIhhknt1FjMEcS8Xoq5vx0O4c1xvjTYenIlb63ibRuFpXASUFGMvAgvDF42QibpvkN0JpjpK6AnSTNg0vDqLJnicmPHs1MHw/132",
    "subscribeTime": "May 29, 2020 7:54:44 PM",
    "unionId": "oZh4guLRAQKmsaXjkn4rEmIkMh3g",//必须提供
    "remark": "",
    "subscribeScene": "ADD_SCENE_SEARCH",
    "qrScene": "0",
    "qrSceneStr": "",
    "appId": "wx32817247717e7333",
    "group": "",
    "userId": 692672045669941256,//可选提供 如果先添加统一用户 后添加粉丝此参数可选 最好注册统一用户后提供
    "fansUpdateTime": "2019-05-29 19:54:46"
  }
]

返回 success 1代表成功 0代表失败

{
    "success": 1,
    "messageCode": 200,
    "message": "成功",
    "result": true,
    "items": null,
    "totalCount": 0
}

获取粉丝 http://192.168.10.40:8081/wx/api/fans/getFans?userId=692672045669941256&portId=4

参数

header:

Sso-Token eyJraWQiOiIiLCJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhcHBsaWNhdGlvbktleSI6IndlY2hhdGNwIiwiaXNzIjoiY21zIiwidXNlck5hbWUiOiJCOTY2QkZCNC00OTNDLTQ0MUEtQkYwMi04RTM3NTA2NDRERTgiLCJncmFudFR5cGUiOiJjbGllbnRDcmVkZW50aWFscyIsImV4cCI6MTU5MDk4MDk4OSwiaWF0IjoxNTkwOTczNzg5fQ.na73QWzgkY1nhaI6R9xD644jBSv_jLnFIqiFaRTsMqwco5D-pNai16-8oZAPBJvZ-FvRSxcv22xb5a4dXV4pNcwcrZJDP4hRdxdz7CsFzkraOaYuTs1Kns1UrN--uuRkP0X0xoZu9_K5FFRyNH6C5GtTKPoJJVFfCXDUvxDDghI

userId 统一用户id portId 端口Id

返回

{
    "success": 1,
    "messageCode": 200,
    "message": "成功",
    "result": {
        "fansId": 55,
        "openId": "oIXH1t-sGaDdgpTWGsMPgqmKwWrQ",
        "subscribe": 1,
        "nickname": "成功",
        "sex": 1,
        "sexDesc": 0,
        "city": "guangzhou",
        "country": "china",
        "province": "guangdong",
        "language": "zh_CN",
        "headImgUrl": "http://thirdwx.qlogo.cn/mmopen/dWYcndbpDnaX98dIhhknt1FjMEcS8Xoq5vx0O4c1xvjTYenIlb63ibRuFpXASUFGMvAgvDF42QibpvkN0JpjpK6AnSTNg0vDqLJnicmPHs1MHw/132",
        "subscribeTime": "2020-05-29T11:54:44.000+0000",
        "unionId": "oZh4guLRAQKmsaXjkn4rEmIkMh3g",
        "remark": "",
        "groupid": null,
        "tagidList": null,
        "subscribeScene": "ADD_SCENE_SEARCH",
        "qrScene": "0",
        "qrSceneStr": "",
        "appId": "wx32817247717e7333",
        "createTime": null,
        "appHostId": null,
        "appPortId": 4,
        "group": "",
        "groups": null,
        "userId": 692672045669941256,
        "fansUpdateTime": "2020-06-03T07:30:56.507+0000",
        "fansCreateTime": "2020-05-28T05:34:08.667+0000"
    },
    "items": null,
    "totalCount": 0
}

微信授权认证重定向 http://mem.360lj.com/mp2/wx/api/fans/authInfo?portid=4&redirectPath=http://mem.360lj.com/mp3 测试环境

http://mem.360lj.com/mp/wx/api/fans/authInfo?portid=2&redirectPath=http://mem.360lj.com/mp3 正式环境

http://mem.360lj.com/mp/wx/api/fans/authInfo?portid=2&redirectPath=http://mem.360lj.com/mp3&authType=snsapi_userinfo

参数 redirectPath 重定向的目标路径 portid 端口id authType 可选参数 默认值 snsapi_userinfo 可以设置值snsapi_base 静默授权

重定向结果

http://mem.360lj.com/mp3/wx/api/fans/authInfo?portid=4&redirectPath=http://mem.360lj.com/mp3&code=011hcG6Q1LWiB41n1B6Q1I4n6Q1hcG6y&state=1&portid=4&appid=wx32817247717e7333&openid=oIXH1t-sGaDdgpTWGsMPgqmKwWrQ&userid=692672045669941256&unionid=oZh4guLRAQKmsaXjkn4rEmIkMh3g

3,添加统一用户

put请求 http://192.168.50.32:13001/mpwechat/wx/api/fans/addUser

参数

header: Sso-Token eyJraWQiOiIiLCJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhcHBsaWNhdGlvbktleSI6IndlY2hhdGNwIiwiaXNzIjoiY21zIiwidXNlck5hbWUiOiJCOTY2QkZCNC00OTNDLTQ0MUEtQkYwMi04RTM3NTA2NDRERTgiLCJncmFudFR5cGUiOiJjbGllbnRDcmVkZW50aWFscyIsImV4cCI6MTU5MDk4MDk4OSwiaWF0IjoxNTkwOTczNzg5fQ.na73QWzgkY1nhaI6R9xD644jBSv_jLnFIqiFaRTsMqwco5D-pNai16-8oZAPBJvZ-FvRSxcv22xb5a4dXV4pNcwcrZJDP4hRdxdz7CsFzkraOaYuTs1Kns1UrN--uuRkP0X0xoZu9_K5FFRyNH6C5GtTKPoJJVFfCXDUvxDDghI

unionId oZh4guLRAQKmsaXjkn4rEmIkMh3g 微信unionId

phone 13145738791 电话号码

{
    "success": 1,
    "messageCode": 200,
    "message": "操作成功!",
    "result": {
        "userId": 692672045669941256,
        "unionId": "oZh4guLRAQKmsaXjkn4rEmIkMh3g",
        "secretPhone": "13145738791",
        "createTime": "2020-05-26T10:28:27.900+0000",
        "updateTime": "2020-05-26T10:28:27.900+0000",
        "appHostId": null,
        "appId": null,
        "appPortId": null,
        "appAppId": null
    },
    "items": null,
    "totalCount": 0
}

返回 success 1代表成功 0代表失败 result:是统一用户对象的json格式 {

"success": 1,
"messageCode": 200,
"message": "操作成功!",
"result": {
    "userId": 692672045669941256,
    "unionId": "oZh4guLRAQKmsaXjkn4rEmIkMh3g",
    "secretPhone": "13145738791",
    "createTime": "2020-05-26T10:28:27.900+0000",
    "updateTime": "2020-05-26T10:28:27.900+0000",
    "appHostId": null,
    "appId": null,
    "appPortId": null,
    "appAppId": null
},
"items": null,
"totalCount": 0

}

4,添加链接访问记录

put请求 http://192.168.50.32:13001/mpwechat/wx/api/fans/addAppPortAccessLog

参数

header: Sso-Token eyJraWQiOiIiLCJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhcHBsaWNhdGlvbktleSI6IndlY2hhdGNwIiwiaXNzIjoiY21zIiwidXNlck5hbWUiOiJCOTY2QkZCNC00OTNDLTQ0MUEtQkYwMi04RTM3NTA2NDRERTgiLCJncmFudFR5cGUiOiJjbGllbnRDcmVkZW50aWFscyIsImV4cCI6MTU5MDk4MDk4OSwiaWF0IjoxNTkwOTczNzg5fQ.na73QWzgkY1nhaI6R9xD644jBSv_jLnFIqiFaRTsMqwco5D-pNai16-8oZAPBJvZ-FvRSxcv22xb5a4dXV4pNcwcrZJDP4hRdxdz7CsFzkraOaYuTs1Kns1UrN--uuRkP0X0xoZu9_K5FFRyNH6C5GtTKPoJJVFfCXDUvxDDghI

portId 4 appId wx32817247717e7333 可选 优先级:portId > appId 查的portId

appAppId 应用id 再应用中心的维护的入口链接的应用id

userId 统一userId

返回 success 1代表成功 0代表失败

{
    "success": 1,
    "messageCode": 200,
    "message": "操作成功!",
    "result": true,
    "items": null,
    "totalCount": 0
}

5,发送消息

post请求 http://192.168.50.32:13001/mpwechat/wx/api/fans/sendMsg

参数

header: Sso-Token eyJraWQiOiIiLCJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhcHBsaWNhdGlvbktleSI6IndlY2hhdGNwIiwiaXNzIjoiY21zIiwidXNlck5hbWUiOiJCOTY2QkZCNC00OTNDLTQ0MUEtQkYwMi04RTM3NTA2NDRERTgiLCJncmFudFR5cGUiOiJjbGllbnRDcmVkZW50aWFscyIsImV4cCI6MTU5MDk4MDk4OSwiaWF0IjoxNTkwOTczNzg5fQ.na73QWzgkY1nhaI6R9xD644jBSv_jLnFIqiFaRTsMqwco5D-pNai16-8oZAPBJvZ-FvRSxcv22xb5a4dXV4pNcwcrZJDP4hRdxdz7CsFzkraOaYuTs1Kns1UrN--uuRkP0X0xoZu9_K5FFRyNH6C5GtTKPoJJVFfCXDUvxDDghI

appAppId 0 在营销中心设置的应用的Id

portId 4 可选 优先级:portId > appId > 根据访问记录接口http://192.168.50.32:13001/mpwechat/wx/api/fans/addAppPortAccessLog 添加的数据查询的最近端口Id

appId wx32817247717e7333 可选 公众号id

userId 692672045669941256 统一用户id

msgType 1 消息类型1 模板消息 2 客服消息

msgTempId 模板Id可选 最优先 如果配置了不根据消息id去找模板id 优先级:msgTempId>msgId 查到的模板消息Id > appAppId+appId 查到的模板消息Id

msgId 培训的消息id 可选

msgContentId 消息内容id 可选 优先级:msgContent>msgContentId>appAppId+appId读取的内容

msgContent 消息内容 可选 最优先 优先级:msgContent>msgContentId>appAppId+appId读取的内容 例如:

[
  {
    "name": "first",
    "value": "首部内容"
  },
  {
    "name": "keyword1",
    "value": "患者姓名"
  },
  {
    "name": "keyword2",
    "value": "预约时间"
  },
  {
    "name": "keyword3",
    "value": "提醒事项"
  },
  {
    "name": "keyword4",
    "value": "医生信息"
  },
  {
    "name": "remark",
    "value": "尾部内容"
  }
]

miniProgramConfigs 小程序配置 可选 如果发的是小程序要配置此项

toUserOpenId 用户openId 根据userId参数获取openId优先 优先级:toUserOpenId> 根据userId查到的openId

url 模板消息打开的url链接

返回 success 1代表成功 0代表失败

{
    "success": 0,
    "messageCode": 500,
    "message": " 错误代码:43004 ,错误信息:需要接收者关注,微信原始报文:{\"errcode\":43004,\"errmsg\":\"require subscribe hint: [OgbjIa05854116]\"}",
    "result": null,
    "items": null,
    "totalCount": 0
}

{
    "success": 1,
    "messageCode": 200,
    "message": "发送成功_1365740038713294848",
    "result": null,
    "items": null,
    "totalCount": 0
}

6.获取应用列表

post 请求 http://192.168.50.32:13001/mpwechat/wx/application/getAll

参数

header: Sso-Token eyJraWQiOiIiLCJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhcHBsaWNhdGlvbktleSI6IndlY2hhdGNwIiwiaXNzIjoiY21zIiwidXNlck5hbWUiOiJCOTY2QkZCNC00OTNDLTQ0MUEtQkYwMi04RTM3NTA2NDRERTgiLCJncmFudFR5cGUiOiJjbGllbnRDcmVkZW50aWFscyIsImV4cCI6MTU5MDk4MDk4OSwiaWF0IjoxNTkwOTczNzg5fQ.na73QWzgkY1nhaI6R9xD644jBSv_jLnFIqiFaRTsMqwco5D-pNai16-8oZAPBJvZ-FvRSxcv22xb5a4dXV4pNcwcrZJDP4hRdxdz7CsFzkraOaYuTs1Kns1UrN--uuRkP0X0xoZu9_K5FFRyNH6C5GtTKPoJJVFfCXDUvxDDghI

{
    "filters": [{"field": "name", "operate": "contains", "value": "qaq"}] ,//可选 不填默认默认[]即可
    "pageIndex": 1 ,//第几页
    "pageSize": 10 ,//页大小
    "sortDirection": 1, //排序方向
    "sortField": "id" ,//排序字段
    "sumFields": [] //默认[] 即可
}

返回


{
	"success": 1,
	"messageCode": 100,
	"message": "操作成功!",
	"result": null,
	"items": [{
		"img": "http://192.168.50.39:8081/public/47CDDCEF-7FAB-4D0D-A65C-EAA113E5412C.jpg",
		"appTypeName": "公众号H5",
		"typeName": "亮健好药网",
		"updateTime": "2020-06-03 17:15:13",
		"type": "3",
		"enterUrl": "http://ue.360lj.com/api/Home/Login?identity=0&backurl=http://ue.360lj.com/dist/doctorHome&appId=27",
		"content": "qaqaqaqaq",
		"rownum": 1,
		"createTime": "2020-06-02 15:21:23",
		"stateName": "正常",
		"appType": "1",
		"name": "qaq",
		"id": 27,
		"state": "0"
	}],
	"totalCount": 1
}