Giter VIP home page Giter VIP logo

Comments (7)

silenceper avatar silenceper commented on May 9, 2024

能把代码贴下吗,看下是怎么发送消息的,怎么配置的?

from wechat.

lancelot96 avatar lancelot96 commented on May 9, 2024

func Wechat(c echo.Context) error {
wc := wechat.NewWechat(&wechat.Config{
Token: "tttttt",
EncodingAESKey: "PrIlmjPSar2cn4ObdrAqMdc82srylFUvMECaUkuM50B",
})

server := wc.GetServer(c.Request(), c.Response().Writer())

server.SetMessageHandler(askForInv)

if err := server.Serve(); err != nil {
	return err
}
return server.Send()

}

func askForInv(msg message.MixMessage) *message.Reply {
article := []*message.Article{}
print("aaa")
switch msg.Content {
case "调查问卷2":
article = append(article, message.NewArticle("调查问卷", "2016年热点问题微调查(第2期)", "", "http://lancelot96/inv1"))
case "调查问卷3":
article = append(article, message.NewArticle("调查问卷", "2016年热点问题微调查(第3期)", "", "http://lancelot96/inv2"))
case "调查统计2":
article = append(article, message.NewArticle("问卷调查统计", "", "", "http://lancelot96/count1"))
case "调查统计3":
article = append(article, message.NewArticle("问卷调查统计", "", "", "http://lancelot96/count2"))
default:
text := message.NewText("参与调查问卷请发送: 调查问卷2或者调查问卷3")

	return &message.Reply{
		message.MsgTypeText,
		text,
	}
}

return &message.Reply{
	message.MsgTypeNews,
	message.NewNews(article),
}

}

from wechat.

silenceper avatar silenceper commented on May 9, 2024

"请求校验失败" 的提示是在收到微信消息校验的时候返回的,可以抓个包看下微信返回的信息。
从上面的代码看不出大问题。

examples目录下的例子能否跑通?

from wechat.

lancelot96 avatar lancelot96 commented on May 9, 2024

唉 配置能通过啊
examples没试过 明天试试

from wechat.

changyu72 avatar changyu72 commented on May 9, 2024

例子存在同样的问题:"请求校验失败"

from wechat.

lancelot96 avatar lancelot96 commented on May 9, 2024

我把我的解决方案说一下
修改作者的代码 在验证的地方加一个条件 如果是get方法就验证

from wechat.

silenceper avatar silenceper commented on May 9, 2024

能否提供一个pr,我这边排查下 ,谢谢。

from wechat.

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.