Rails4 集成测试微信公众号API
这是一个简单集成微信api的的例子,使用这个Gem:https://github.com/lanrion/weixin_rails_middleware
- 下载这个rails4例子到本地 https://github.com/caiwenhn2008/weixin_rails_middleware_example
2.运行
bundle exec bundle install
- 启动服务器,http://localhost:3000/
rails server
- 根据下面的例子安装,启动 localtunnelling : http://caerun.iteye.com/admin/blogs/2271660
得到这个映射的公网地址:https://gtxzozgorw.localtunnel.me
- 在http://localhost:3000/创建用户,微信token,如下:

6.所以本地微信应用对应的公网地址: https://gtxzozgorw.localtunnel.me/weixin/4-kov581d4uewerdtb4joj3uywbv-hhgy1i_zroabmq Token is: 14fc9031f12fd684359c7a05
-
登陆微信公众平台: http://mp.weixin.qq.com/debug/cgi-bin/sandboxinfo?action=showinfo&t=sandbox/index

-
用微信扫描你自己的微信公众测试号

-
关注微信号码后可以发任何信息测试一下,得到一个相同的回复信息
-
可以查看weixin_controller_decorator.rb如何客户化返回信息
更多请参考原作者github: https://github.com/lanrion/weixin_rails_middleware