Comments (8)
type Request struct {
XMLName struct{} `xml:"xml" json:"-"`
CommonHead
// fuck weixin, MsgId != MsgID
MsgId int64 `xml:"MsgId"`
MsgID int64 `xml:"MsgID"`
Content string `xml:"Content,omitempty"`
MediaId string `xml:"MediaId,omitempty"`
PicURL string `xml:"PicUrl,omitempty"`
Format string `xml:"Format,omitempty"`
Recognition string `xml:"Recognition,omitempty"`
ThumbMediaId string `xml:"ThumbMediaId,omitempty"`
LocationX float64 `xml:"Location_X,omitempty"`
LocationY float64 `xml:"Location_Y,omitempty"`
Scale int `xml:"Scale,omitempty"`
Label string `xml:"Label,omitempty"`
Title string `xml:"Title,omitempty"`
Description string `xml:"Description,omitempty"`
URL string `xml:"Url,omitempty"`
Event string `xml:"Event,omitempty"`
EventKey string `xml:"EventKey,omitempty"`
Ticket string `xml:"Ticket,omitempty"`
Latitude float64 `xml:"Latitude,omitempty"`
Longitude float64 `xml:"Longitude,omitempty"`
Precision float64 `xml:"Precision,omitempty"`
Status string `xml:"Status,omitempty"`
TotalCount int `xml:"TotalCount,omitempty"`
FilterCount int `xml:"FilterCount,omitempty"`
SentCount int `xml:"SentCount,omitempty"`
ErrorCount int `xml:"ErrorCount,omitempty"`
OrderId string `xml:"OrderId,omitempty"`
OrderStatus int `xml:"OrderStatus,omitempty"`
ProductId string `xml:"ProductId,omitempty"`
SkuInfo string `xml:"SkuInfo,omitempty"`
}
from wechat.
谢谢你的 issue,这是我的第一个 issue,哈哈。
这个 Request 我不是设计的给用户用的,只是内部使用的,我暴露给你们的是具体的消息类型:
// 文本消息
//
// <xml>
// <ToUserName><![CDATA[gh_xxxxxxxxxxxx]]></ToUserName>
// <FromUserName><![CDATA[os-IKuHd9pJ6xsn4mS7GyL4HxqI4]]></FromUserName>
// <CreateTime>1406600283</CreateTime>
// <MsgType><![CDATA[text]]></MsgType>
// <Content><![CDATA[测试]]></Content>
// <MsgId>6041302214229962560</MsgId>
// </xml>
type Text struct {
XMLName struct{} `xml:"xml" json:"-"`
CommonHead
MsgId int64 `xml:"MsgId" json:"MsgId"` // 消息id, 64位整型
Content string `xml:"Content" json:"Content"` // 文本消息内容
}
func (req *Request) Text() (text *Text) {
text = &Text{
CommonHead: req.CommonHead,
MsgId: req.MsgId,
Content: req.Content,
}
return
}
在 github.com/chanxuehong/wechat/server 里面你们接受到的应该是这样的具体类型的消息,而不是
Request,所以我就没有考虑到这个 Request 的格式化问题了。
不知道你是怎么使用的,为什么有这个需求???
from wechat.
因为我们需要内部把微信的消息转给其他的应用,所以如果是不加empty,就会导致其他的程序解析错误,因为其他的程序使用的不是go,有用node的,有用php的,解析都是按照微信的标准来的;
from wechat.
哦,如果是这样那基本上不用我的库了,你要的只是一个request结构,那样完全可以自己来实现这个结构啊!
不过我加上那个也行,不冲突,等下回去加上吧
from wechat.
对了,你在群里么,如果在等下给我一个消息,我回家和你聊。
你刚才说的转发给其他的应用可以把原始信息给他啊,不用解析然后再marshal吧
from wechat.
因为每一个请求都是通过几个过程来处理的,第一步会先用这个类库处理成Request,然后如果需要就把这个请求转发给其他的应用,所以这个过程中已经没有原始的xml了
from wechat.
虽然还不知道你具体的应用场景,但是还是给你加上了,这个没有大的影响。
你既然都解析出来了,可以用具体的类型做xml然后再转给其他应用啊,干嘛非要揪住request不放???
from wechat.
谢啦,因为转发的函数的参数使用的*Request,他不需要知道具体的类型
from wechat.
Related Issues (20)
- 这儿有文档解释有点小问题。pagePath 应该是说是小程序的页面
- 测试实践后 模板小程序部分参数 微信文档与微信后台不一致。这儿的pagepath实际为path。否则 模板报错"errcode":40165 HOT 1
- 建议:添加微信 仿真系统功能
- 刚提交了pull requests,新增对客服消息中的菜单消息的支持,能帮忙merge一下么 HOT 1
- 微信access_token中控服务器 HOT 7
- mp部分文档是否有问题?
- 没文档? HOT 4
- 建议把v1 v2打成tag,好让go module拉取
- 有没大神给个gin调用的例子呢 HOT 2
- 媒体/素材涉及Download的方法,在文件扩展名未知的情况下,如何传filepath参数?
- 微信个人号的API 推荐大家看这个 https://wkteam.gitbook.io/api/ HOT 1
- 吐槽一下,怎么调 全靠看源码 , fuck 弃坑 HOT 1
- 支持小程序支付吗?
- amr 怎么转mp3格式,有工具类么?
- 能提供文档介绍下怎么使用吗
- 企业微信群控CRM
- 有没有自动提交小程序代码和提交审核?
- 出现了xml解析的panic HOT 1
- go不弄个发红包码 HOT 2
- 请问支持企业微信SDK么? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wechat.