知识点
相关文章
更多最近更新
更多顶 使用Rails plugin weixin_rails_middleware 快速搭建微信营销平台
2019-03-02 00:07|来源: 网路
weixin_rails_middleware,是专门为Rails项目开发微信第三方营销平台的gem,此gem已经在公司内部使用,
Github链接: https://github.com/lanrion/weixin_rails_middleware
Github example: https://github.com/lanrion/weixin_rails_middleware_example
使用方法:
gem 'weixin_rails_middleware'
bundle install
rails generate weixin_rails_middleware:install
配置 config/initializers/weixin_rails_middleware.rb
如果你只是固定的一个token值,那么只需要配置 config.token_string="你的token值"
生成的链接 http://example.com/weixin/你的token值
如果你像微盟那样,有很多用户添加自己公众账号,那个配置
config.token_model="你保存公众账号的Model名称"
config.token_column="保存token的字段", 默认为"weixin_token"
生成的链接 http://example.com/weixin/生成的token值
自动验证微信请求。
无需拼接XML格式,只需要使用
WeixinMessageHelper
辅助方法,即可快速回复。 使用方法:render xml: reply_text_message("Your Message: #{current_message.Content}")
支持自定义token,适合一个用户使用。
支持多用户token: 适合多用户注册网站,每个用户有不同的token,通过
weixin_rails_middleware.rb
配置好存储token的Model与字段名,即可。文本回复:
reply_text_message(content)
。音乐回复:
reply_music_message(music)
,generate_music(title, desc, music_url, hq_music_url)
。图文回复:
reply_news_message(articles)
,generate_article(title, desc, pic_url, link_url)
。视频回复:
replay_video_message(video)
。语音回复:
reply_voice_message(voice)
。图片回复:
reply_imgage_message(image)
。地理位置回复: 自定义需求。
更多请直接访问
Github链接: https://github.com/lanrion/weixin_rails_middleware
转自:http://my.oschina.net/u/200705/blog/201321
相关问答
更多-
我见过的最棒的是Devise 。 你也可以尝试authlogic ,但我建议第一个。 与康肯这样的授权宝石一起使用会让您的生活更轻松。 这里的第209集关于设计 (也检查210更多定制) 我遵循本教程在cancan和devise之间进行了组合,并且它“像这样”(也是该教程的第2部分 ) the best i've seen do far is Devise. You could also try authlogic, but i'd recommend the first one. Used with an ...
-
这里的问题是我使用gem安装了rails 2.3.4,但是已经将项目的2.2.2版本复制到了Helicon Zoo Web根目录。 actionpack lib是rails的一部分。 我以为这是一个单独的图书馆。 The problem here was that I had installed rails 2.3.4 with gem but had copied a 2.2.2 version of rails with the project to the Helicon Zoo web root d ...
-
也许这会有所帮助: http : //github.com/bcardarella/decoder Maybe this would help: http://github.com/bcardarella/decoder
-
您可以在config / initializers中创建一个新文件,例如globals.rb: EXTERNAL_SERVICE_IP_1 = "some ip" You could create a new file in config/initializers, e.g. globals.rb: EXTERNAL_SERVICE_IP_1 = "some ip"
-
尽可能安装宝石版的东西。 您可以通过插件获得以下好处: 您可以在特定环境中启用或禁用它们 您可以通过gem update更新它们。 使用插件,您必须自己手动外出并自行更新。 它们是系统共享的,因此如果您创建一个新项目,则可以使用它们,而无需在以前的项目中使用它们时重新安装它们。 你必须复制/粘贴插件。 插件特定于导轨,但宝石不是。 可以在Rails之外使用gem。 您仍然可以通过运行rake gems:unpack压缩gems到您的供应商目录rake gems:unpack 。 这对于将宝石“锁定”到当前版 ...
-
Rails 3私信消息插件(Rails 3 private message plugin)[2022-06-24]
重新启动服务器。 他们的插件可能没有加载。 Restart your Server. They plugin may not have loaded. -
我建议你使用Devise插件。 它工作得很好。 然后你可以添加Ryan Bates编写的CanCan插件 祝你好运 ! I advise you to use the Devise plugin. It works very well. You can then add CanCan plugin written by Ryan Bates Good luck !
-
Ruby on Rails博客(Ruby on Rails Blog)[2022-01-14]
尝试使用Mephisto PS:在谷歌搜索“rails博客引擎”,你会发现很多其他的点击。 Try using Mephisto PS: Search for "rails blog engine" in Google and you will find many other hits. -
rails3顶部的肥皂服务(soap service on the top of rails3)[2021-10-09]
你可以从actionwebservice和soap4r gems尝试这个最新的问题: https : //github.com/roundlake/actionwebservice https://github.com/bbhoss/soap4r You can try this latest forks from actionwebservice and soap4r gems: https://github.com/roundlake/actionwebservice https://github.co ... -
Rails 3有一个发电机。 根据插件的其余部分,您可能需要进行修改才能使Rails 3兼容。 您可以像这样运行生成器: rails generate ... Rails 3 has a generator. Depending on the rest of the plugin though you might have to make modifications to make it Rails 3 compatible. You can run the generator like this: ra ...