添加xml格式解析
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
package enterprise_wechat
|
package enterprise_wechat
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/xml"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -9,10 +9,14 @@ import (
|
|||||||
|
|
||||||
// 回调参数
|
// 回调参数
|
||||||
type SuiteTicketInfo struct {
|
type SuiteTicketInfo struct {
|
||||||
SuiteId string // 第三方应用的SuiteId
|
SuiteId string `xml:"SuiteId"` // 第三方应用的SuiteId
|
||||||
InfoType string // suite_ticket
|
InfoType string `xml:"InfoType"` // suite_ticket
|
||||||
TimeStamp int64 // 时间戳
|
TimeStamp int64 `xml:"TimeStamp"` // 时间戳
|
||||||
SuiteTicket string // Ticket内容,最长为512字节
|
SuiteTicket string `xml:"SuiteTicket"` // Ticket内容,最长为512字节
|
||||||
|
}
|
||||||
|
|
||||||
|
type SuiteTicketXml struct {
|
||||||
|
Xml *SuiteTicketInfo `xml:"xml"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) GetEnterpriseMsg(request *http.Request) (*SuiteTicketInfo, error) {
|
func (a *API) GetEnterpriseMsg(request *http.Request) (*SuiteTicketInfo, error) {
|
||||||
@@ -21,10 +25,12 @@ func (a *API) GetEnterpriseMsg(request *http.Request) (*SuiteTicketInfo, error)
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
globals.SugarLogger.Debug("data============enterprise", data)
|
globals.SugarLogger.Debug("data============enterprise", data)
|
||||||
|
globals.SugarLogger.Debug("data============enterprise", string(data))
|
||||||
|
|
||||||
suite := &SuiteTicketInfo{}
|
suite := &SuiteTicketInfo{}
|
||||||
if err := json.Unmarshal(data, suite); err != nil {
|
if err := xml.Unmarshal(data, suite); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return suite, err
|
return suite, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user