Rails4 集成测试微信公众号API

这是一个简单集成微信api的的例子,使用这个Gem:https://github.com/lanrion/weixin_rails_middleware


1. 下载这个rails4例子到本地
[url]https://github.com/caiwenhn2008/weixin_rails_middleware_example[/url]

2.运行
bundle exec bundle install


3. 启动服务器,http://localhost:3000/
rails server


4. 根据下面的例子安装,启动 localtunnelling :
[url]http://caerun.iteye.com/admin/blogs/2271660[/url]

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

5. 在http://localhost:3000/创建用户,微信token,如下:
[img]http://dl2.iteye.com/upload/attachment/0114/5991/b7d42543-8a80-384c-93bd-e07043d6ec36.png[/img]


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

7. 登陆微信公众平台: http://mp.weixin.qq.com/debug/cgi-bin/sandboxinfo?action=showinfo&t=sandbox/index
[img]http://dl2.iteye.com/upload/attachment/0114/5993/7d4c22b8-87db-3a2d-8dce-06ace79f87b8.png[/img]

8. 用微信扫描你自己的微信公众测试号
[img]http://dl2.iteye.com/upload/attachment/0114/5995/70275f28-3a32-373b-9c41-7c3b19c0b968.png[/img]


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

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

更多请参考原作者github: https://github.com/lanrion/weixin_rails_middleware
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值