Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

发模板消息内容是空的 #20

Closed
TomLiu-GitHub opened this issue Jun 1, 2019 · 2 comments
Closed

发模板消息内容是空的 #20

TomLiu-GitHub opened this issue Jun 1, 2019 · 2 comments

Comments

@TomLiu-GitHub
Copy link
Contributor

代码如下

	tlpdata:= map[string]struct {
		value string
		color string
	}{"first": {value: "我是渣渣涛", color: "#173177"},
		"keyword1": {value: "这是一个你从没有玩过的全新游戏", color: "#173177"},
		"keyword2": {value: "只要你跟着我一起试玩一下", color: "#173177"},
		"keyword3": {value: "你就会爱上这款游戏", color: "#4B1515"},
		"remark":   {value: "是兄弟就来砍我", color: "#071D42"},
	}
	msgid,_ := ctx.SendTemplate(
		ctx.Msg.FromUserName,
		"tempid",
		c.Request.Host,
		ctx.AppId,
		"",
		tlpdata,
	)

效果如下

image

@esap
Copy link
Owner

esap commented Jun 1, 2019

由于go语言json解析的特殊性,需要大写字段才能导出,struct结构可改为如下方式:

	tlpdata := map[string]struct {
		Value string `json:"value"`
		Color string `json:"color"`
	}{
		"first": {Value: "我是渣渣涛", Color: "#173177"},
		"keyword1": {Value: "这是一个你从没有玩过的全新游戏", Color: "#173177"},
		"keyword2": {Value: "只要你跟着我一起试玩一下", Color: "#173177"},
		"keyword3": {Value: "你就会爱上这款游戏", Color: "#4B1515"},
		"remark":   {Value: "是兄弟就来砍我", Color: "#071D42"},
	}

@esap esap closed this as completed Jun 1, 2019
@TomLiu-GitHub
Copy link
Contributor Author

太久没玩go了,你一说我突然就想起来了.感谢感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants