Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

企业微信客服开发的文档不太好理解 没找到 OpenKfId #416

Closed
mofadeyunduo opened this issue Nov 27, 2023 · 10 comments
Closed

Comments

@mofadeyunduo
Copy link

https://powerwechat.artisan-cloud.com/zh/wecom/server.html#%E5%BC%80%E5%A7%8B%E6%8E%A5%E6%94%B6%E6%B6%88%E6%81%AF
在这里怎么接收客服消息呢

我查到了事件是 CALLBACK_EVENT_KF_MSG_OR_EVENT 没看到对应结构体 我尝试搜索结构体 不应该有 OpenKfId 字段么,参考这个文档 https://developer.work.weixin.qq.com/document/path/90238#12977,没搜到如何读取 OpenKfId

@mofadeyunduo
Copy link
Author

应该用什么
msg := models.???{}

image
没有
image
OpenKfId

@mofadeyunduo
Copy link
Author

type RequestAccountServiceSendMsg struct {
ToUser string json:"touser"
OpenKfid string json:"open_kfid"
MsgID string json:"msgid"
MsgType string json:"msgtype"
Text RequestAccountServiceMsgText json:"text,omitempty"
Image RequestAccountServiceMsgImage json:"image,omitempty"
Voice RequestAccountServiceMsgVoice json:"voice,omitempty"
File RequestAccountServiceMsgFile json:"file,omitempty"
Link RequestAccountServiceMsgLink json:"link,omitempty"
MiniProgram RequestAccountServiceMsgMiniProgram json:"miniprogram,omitempty"
Menu RequestAccountServiceMsgMenu json:"msgmenu,omitempty"
Location RequestAccountServiceMsgLocation json:"location,omitempty"
}
这个发消息的对象是不是有点问题吧,应该是 *RequestAccountServiceMsgText,不然 omitempty 没用吧

@Matrix-X
Copy link
Contributor

type RequestAccountServiceSendMsg struct {
ToUser string json:"touser"
OpenKfid string json:"open_kfid"
MsgID string json:"msgid"
MsgType string json:"msgtype"
Text RequestAccountServiceMsgText json:"text,omitempty"
Image RequestAccountServiceMsgImage json:"image,omitempty"
Voice RequestAccountServiceMsgVoice json:"voice,omitempty"
File RequestAccountServiceMsgFile json:"file,omitempty"
Link RequestAccountServiceMsgLink json:"link,omitempty"
MiniProgram RequestAccountServiceMsgMiniProgram json:"miniprogram,omitempty"
Menu RequestAccountServiceMsgMenu json:"msgmenu,omitempty"
Location RequestAccountServiceMsgLocation json:"location,omitempty"
}
这个发消息的对象是不是有点问题吧,应该是 *RequestAccountServiceMsgText,不然 omitempty 没用吧

你看到挺仔细,这个请查看最新的版本 : https://github.com/ArtisanCloud/PowerWeChat/tree/v3.1.13
已经追加了*

@Matrix-X
Copy link
Contributor

应该用什么 msg := models.???{}

image 没有 image OpenKfId

我新加了一个数据类型
image

具体使用方法是:

通过GetEvent后,再通过定义个事件内容结构体,通过event.ReadMessage(&msg)去解析获取。
image

我已经上传到develop分支了,请试着用一下,如果没问题,我可以打一个版本

如果有问题,请随时添加我的微信,我可以帮助协助

@mofadeyunduo
Copy link
Author

type RequestAccountServiceSendMsg struct {
ToUser string json:"touser"
OpenKfid string json:"open_kfid"
MsgID string json:"msgid"
MsgType string json:"msgtype"
Text RequestAccountServiceMsgText json:"text,omitempty"
Image RequestAccountServiceMsgImage json:"image,omitempty"
Voice RequestAccountServiceMsgVoice json:"voice,omitempty"
File RequestAccountServiceMsgFile json:"file,omitempty"
Link RequestAccountServiceMsgLink json:"link,omitempty"
MiniProgram RequestAccountServiceMsgMiniProgram json:"miniprogram,omitempty"
Menu RequestAccountServiceMsgMenu json:"msgmenu,omitempty"
Location RequestAccountServiceMsgLocation json:"location,omitempty"
}
这个发消息的对象是不是有点问题吧,应该是 *RequestAccountServiceMsgText,不然 omitempty 没用吧

你看到挺仔细,这个请查看最新的版本 : https://github.com/ArtisanCloud/PowerWeChat/tree/v3.1.13 已经追加了*

主要是我在开发企业微信客服...此外帮忙检查一下这些对象吧,很多都是 optional 的,比如 MsgID string json:"msgid",这个字段没加上 omitempty 传到微信会提示不合法的空字符串 msgid,必须要 omit 掉...

@Matrix-X
Copy link
Contributor

pls check v3.1.15

帮你添加了omit for

type RequestAccountServiceSendMsg struct {
ToUser string json:"touser"
OpenKfid string json:"open_kfid"
MsgID string json:"msgid,omitempty"
MsgType string json:"msgtype,omitempty"
Text *RequestAccountServiceMsgText json:"text,omitempty"
Image *RequestAccountServiceMsgImage json:"image,omitempty"
Voice *RequestAccountServiceMsgVoice json:"voice,omitempty"
File *RequestAccountServiceMsgFile json:"file,omitempty"
Link *RequestAccountServiceMsgLink json:"link,omitempty"
MiniProgram *RequestAccountServiceMsgMiniProgram json:"miniprogram,omitempty"
Menu *RequestAccountServiceMsgMenu json:"msgmenu,omitempty"
Location *RequestAccountServiceMsgLocation json:"location,omitempty"
}

@mofadeyunduo
Copy link
Author

thx 有空我就测一下 实在是太忙了

@mofadeyunduo
Copy link
Author

image
这个接口最后一个参数是选填...

@mofadeyunduo
Copy link
Author

哦 抱歉 看到了 hashmap 结构你们过滤了

@Matrix-X
Copy link
Contributor

哦 抱歉 看到了 hashmap 结构你们过滤了

no problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants