新手问题 [求助] rails5,接收微信消息,获取不到 xml

yuanjie · April 19, 2018 · Last by yuanjie replied at April 19, 2018 · 1053 hits

最近做一个微信项目,用 rails 做服务,在获取用户消息时,始终拿不到 xml 数据,不知道是什么问题,求大神相助

微信的 xml 不会自动进入到 params,如果你想在 rails 5 下用,可以看看这https://github.com/rails/actionpack-xml_parser

不过简单点可以这样干

xml_message = Hash.from_xml(request.raw_post).fetch('xml', {})
Reply to adamshen

果然是,谢谢,解决了

Reply to adamshen

我同事说认识你,你在 Tower 上班?

Reply to yuanjie

你同事是谁?我不在 Tower

Reply to adamshen

可能认错了,他叫任巍林

You need to Sign in before reply, if you don't have an account, please Sign up first.