github.com/chanxuehong/wechat@v0.0.0-20230222024006-36f0325263cd/mp/card/mpnews/gethtml.go (about) 1 package mpnews 2 3 import ( 4 "github.com/chanxuehong/wechat/mp/core" 5 ) 6 7 // 获取卡券嵌入图文消息的标准格式代码. 8 // 9 // 将返回代码填入上传图文素材接口中content字段,即可获取嵌入卡券的图文消息素材。 10 func GetHTML(clt *core.Client, cardId string) (content string, err error) { 11 request := struct { 12 CardId string `json:"card_id"` 13 }{ 14 CardId: cardId, 15 } 16 17 var result struct { 18 core.Error 19 Content string `json:"content"` 20 } 21 22 incompleteURL := "https://api.weixin.qq.com/card/mpnews/gethtml?access_token=" 23 if err = clt.PostJSON(incompleteURL, &request, &result); err != nil { 24 return 25 } 26 27 if result.ErrCode != core.ErrCodeOK { 28 err = &result.Error 29 return 30 } 31 content = result.Content 32 return 33 }