結(jié)構(gòu)體如下:
type WxPushContent struct { Push_record_id int `json:"push_record_id"` Template_id string `json:"template_id"` Page string `json:"page"` Data Data `json:"data"` Emphasis_keyword string `json:"emphasis_keyword"` } type Data struct { Keyword1 WxKeyword `json:"keyword1"` Keyword2 WxKeyword `json:"keyword2"` Keyword3 WxKeyword `json:"keyword3"` } type WxKeyword struct { Value string `json:"value"` } 實(shí)際代碼如下: func ExecutePush_WX(ctx *gin.Context) { var json_iterator = jsoniter.ConfigCompatibleWithStandardLibrary jsonWxPushContent, _ := json_iterator.Marshal(models.WxPushContent{ Push_record_id: note.Id, Template_id: setting.MINITemplateId, Page: "/pages/detail?isShare=true&isFromPush=" + strconv.Itoa(note.Id) + "&id=" + strconv.FormatInt(note.NewsId, 10), Data: models.Data{ Keyword1:models.WxKeyword{Value: "熱點(diǎn)新聞"}, Keyword2:models.WxKeyword{Value: news.Title}, Keyword3:models.WxKeyword{Value: tt[0].Summary}, }, Emphasis_keyword: "keyword1.DATA"}) } |
log.Println("小程序-加密前的參數(shù): ", string(jsonWxPushContent))
返回結(jié)果:
{ "push_record_id":33, "template_id":"3OviTbpRI-7t8GJxlaoKtyQM6SuOXnROVk-jwj-T-GI", "page":"/pages/detail?isShare=true&isFromPush=33&id=63688", "data":{ "keyword1":{ "value":"熱點(diǎn)新聞" }, "keyword2":{ "value":"人工智能是否會(huì)顛覆傳統(tǒng)電視行業(yè)?" }, "keyword3":{ "value":"據(jù)了解,近日長(zhǎng)虹再次與人工智能領(lǐng)先企業(yè)達(dá)觀數(shù)據(jù)達(dá)成合作,將電視內(nèi)容的個(gè)性化推薦引入智能電視,為用戶(hù)更好的打造智慧家庭體系" } } "emphasis_keyword":"keyword1.DATA" }
工作日 8:30-12:00 14:30-18:00
周六及部分節(jié)假日提供值班服務(wù)