ITeye博客

Rails4 集成测试微信公众号API

caiwenhn2008 · 2016-01-17 20:34 · Ruby&Rails · Web前端 · Markdown

这是一个简单集成微信api的的例子,使用这个Gem:https://github.com/lanrion/weixin_rails_middleware
  1. 下载这个rails4例子到本地 https://github.com/caiwenhn2008/weixin_rails_middleware_example

2.运行

bundle exec bundle install
  1. 启动服务器,http://localhost:3000/
rails server
  1. 根据下面的例子安装,启动 localtunnelling : http://caerun.iteye.com/admin/blogs/2271660

得到这个映射的公网地址:https://gtxzozgorw.localtunnel.me

  1. 在http://localhost:3000/创建用户,微信token,如下:

6.所以本地微信应用对应的公网地址: https://gtxzozgorw.localtunnel.me/weixin/4-kov581d4uewerdtb4joj3uywbv-hhgy1i_zroabmq Token is: 14fc9031f12fd684359c7a05

  1. 登陆微信公众平台: http://mp.weixin.qq.com/debug/cgi-bin/sandboxinfo?action=showinfo&t=sandbox/index

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

  3. 关注微信号码后可以发任何信息测试一下,得到一个相同的回复信息

  4. 可以查看weixin_controller_decorator.rb如何客户化返回信息

更多请参考原作者github: https://github.com/lanrion/weixin_rails_middleware

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。