Giter Club home page Giter Club logo

Comments (13)

puppet-king avatar puppet-king commented on May 14, 2024 1

SubscribeMessage 结构还是 string, 在 json 编码的时候会加上转移符,仍然无法使用撒

看到另外一个 issues 了, 打扰了

from weapp.

JiajunDou avatar JiajunDou commented on May 14, 2024
type SubscribeMessage struct {
	ToUser           string                 `json:"touser"`
	TemplateID       string                 `json:"template_id"`
	Page             string                 `json:"page,omitempty"`
	MiniprogramState MiniprogramState       `json:"miniprogram_state,omitempty"`
	Data             map[string]interface{} `json:"data"`
}

这里应该是 map[string]interface{}

from weapp.

royalrick avatar royalrick commented on May 14, 2024

谢谢指正 应该是 subscribemessage.MiniprogramStateDeveloper

from weapp.

royalrick avatar royalrick commented on May 14, 2024
type SubscribeMessage struct {
	ToUser           string                 `json:"touser"`
	TemplateID       string                 `json:"template_id"`
	Page             string                 `json:"page,omitempty"`
	MiniprogramState MiniprogramState       `json:"miniprogram_state,omitempty"`
	Data             map[string]interface{} `json:"data"`
}

这里应该是 map[string]interface{}

v2 用的是map,但是在实际应用中不是很好转换和使用,所以考虑在v3使用微信接口原生的string类型;

from weapp.

royalrick avatar royalrick commented on May 14, 2024
type SubscribeMessage struct {
	ToUser           string                 `json:"touser"`
	TemplateID       string                 `json:"template_id"`
	Page             string                 `json:"page,omitempty"`
	MiniprogramState MiniprogramState       `json:"miniprogram_state,omitempty"`
	Data             map[string]interface{} `json:"data"`
}

这里应该是 map[string]interface{}

v2 用的是map,但是在实际应用中不是很好转换和使用,所以考虑在v3使用微信接口原生的string类型;

from weapp.

JiajunDou avatar JiajunDou commented on May 14, 2024

package weapp

weapp.MiniprogramStateDeveloper

subscribemessage.MiniprogramStateDeveloper IDE会直接报错

from weapp.

royalrick avatar royalrick commented on May 14, 2024

截屏2021-09-21 上午7 57 55

试了下没问题呢

from weapp.

JiajunDou avatar JiajunDou commented on May 14, 2024

引用import weapp开发 按照文档会报错

from weapp.

royalrick avatar royalrick commented on May 14, 2024

from weapp.

codingcn avatar codingcn commented on May 14, 2024

看下具体的错误是啥呢 VENI VIDI VICI

在 2021年9月21日,上午8:45,JiajunDou @.***> 写道:  引用import weapp开发 按照文档会报错 — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

订阅消息data为string,我这边一直提示参数错误,没找出是什么原因

这是我的代码

res, err1 := miniapp.MiniAppCli.SendSubscribeMsg(&weapp.SubscribeMessage{
	ToUser:           "o4Q0Y5Xt1Kx0xp3hIw-luS1xHGO0",
	TemplateID:       "p2Byu2vTmAPiuYo_Kwrgg6xr9j_2QtssGHQ1uX2IT7Y",
	Page:             "pages/index/index",
	MiniprogramState: weapp.MiniprogramStateDeveloper,
	Data:             `{"name1":{"value":"11111"},"time3":{"value":"3333"},"thing7":{"value":"7777"}}`,
})
fmt.Println("订阅消息响应", res,err1)

下面是报错data.name1.value is emtpy

2021/10/15 16:46:18 [info] request params: &{ToUser:o4Q0Y5Xt1Kx0xp3hIw-luS1xHGO0 TemplateID:p2Byu2vTmAPiuYo_Kwrgg6xr9j_2QtssGHQ1uX2IT7Y Page:pages/index/index MiniprogramState:developer Data:{"name1":{"value":"11111"},"time3":{"value":"3333"},"thing7":{"value":"7777"}}}

订阅消息响应 &{47003 argument invalid! data.name1.value is emtpy rid: 61693fdb-4e573d1c-6310270b} <nil>

from weapp.

codingcn avatar codingcn commented on May 14, 2024

@royalrick
我自己把data改成map类型,结果发送成功了。

// SubscribeMessage 订阅消息
type SubscribeMessage struct {
	ToUser           string           `json:"touser"`
	TemplateID       string           `json:"template_id"`
	Page             string           `json:"page,omitempty"`
	MiniprogramState MiniprogramState `json:"miniprogram_state,omitempty"`
	Data             map[string]interface{}       `json:"data"`
}

from weapp.

royalrick avatar royalrick commented on May 14, 2024

已经修复,谢谢:)

from weapp.

puppet-king avatar puppet-king commented on May 14, 2024

SubscribeMessage 结构还是 string, 在 json 编码的时候会加上转移符,仍然无法使用撒

from weapp.

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.