Giter VIP home page Giter VIP logo

Comments (8)

magicshui avatar magicshui commented on May 10, 2024
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.

chanxuehong avatar chanxuehong commented on May 10, 2024

谢谢你的 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.

magicshui avatar magicshui commented on May 10, 2024

因为我们需要内部把微信的消息转给其他的应用,所以如果是不加empty,就会导致其他的程序解析错误,因为其他的程序使用的不是go,有用node的,有用php的,解析都是按照微信的标准来的;

from wechat.

chanxuehong avatar chanxuehong commented on May 10, 2024

哦,如果是这样那基本上不用我的库了,你要的只是一个request结构,那样完全可以自己来实现这个结构啊!
不过我加上那个也行,不冲突,等下回去加上吧

from wechat.

chanxuehong avatar chanxuehong commented on May 10, 2024

对了,你在群里么,如果在等下给我一个消息,我回家和你聊。

你刚才说的转发给其他的应用可以把原始信息给他啊,不用解析然后再marshal吧

from wechat.

magicshui avatar magicshui commented on May 10, 2024

因为每一个请求都是通过几个过程来处理的,第一步会先用这个类库处理成Request,然后如果需要就把这个请求转发给其他的应用,所以这个过程中已经没有原始的xml了

from wechat.

chanxuehong avatar chanxuehong commented on May 10, 2024

虽然还不知道你具体的应用场景,但是还是给你加上了,这个没有大的影响。

你既然都解析出来了,可以用具体的类型做xml然后再转给其他应用啊,干嘛非要揪住request不放???

from wechat.

magicshui avatar magicshui commented on May 10, 2024

谢啦,因为转发的函数的参数使用的*Request,他不需要知道具体的类型

from wechat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.