对接企业微信应答:
https://github.com/lanrion/qy_wechat
(对应公众号gem:https://github.com/lanrion/weixin_rails_middleware)
安装
目前只有Master稳定版本,务必通过:
gem 'qy_wechat', git: 'https://github.com/lanrion/qy_wechat.git'
安装。
使用
示例:https://github.com/lanrion/qy_wechat_example
rails g qy_wechat:install rails g qy_wechat:migration QyApp # QyAapp 你保存企业号应用的Model
分别会产生:
配置保存企业微信账号的Model:qy_wechat_example/config/initializers/qy_wechat_config.rb
这里实现你的业务逻辑:qy_wechat_example/app/decorators/controllers/qy_wechat/qy_wechat_controller_decorator.rb
同时添加以下4个字段:
- qy_token
- encoding_aes_key # 长度固定为43个字符,从a-z, A-Z, 0-9共62个字符中选取
- corp_id
- qy_secret_key # 用于标志属于哪个应用
特别注意: 由于一个企业号,可以对应多个应用,可以根据 corp_id
关联你保存对应的企业号应用。
最后在你的QyApp中添加如下代码生成你的qy_secret_key:
class QyApp < ActiveRecord::Base before_create :init_qy_secret_key private def init_qy_secret_key self.qy_secret_key = SecureRandom.hex(8) end end
生成服务验证URL
qy_wechat_engine.qy_verify_url(qy_app.qy_secret_key)
issue
欢迎提交使用中的bug,或者改进意见:https://github.com/lanrion/qy_wechat/issues/new
QyWechatApi
企业微信高级API
https://rubygems.org/gems/qy_wechat_api
企业号对应多个管理组,请前往 设置
=> 权限管理
任意创建一个管理组,在管理组最下角即可获取 CorpID Secret
有问题请及时提issue
gem "qy_wechat_api", git: "https://github.com/lanrion/qy_wechat_api.git"
Token 存储方案
对象存储
如果你是单个企业号,建议使用这个方案,无需任何配置即可使用。
Redis 存储
redis = Redis.new(host: "127.0.0.1", port: "6379") namespace = "qy_wechat_api:redis_storage" # cleanup keys in the current namespace when restart server everytime. exist_keys = redis.keys("#{namespace}:*") exist_keys.each{|key|redis.del(key)} redis_with_ns = Redis::Namespace.new("#{namespace}", redis: redis) QyWechatApi.configure do |config| config.redis = redis_with_ns end
API基本用法
请务必结合:http://qydev.weixin.qq.com/wiki/index.php 理解以下API参数使用。
初始化
group_client = QyWechatApi::Client.new(corpid, corpsecret) # 为了确保用户输入的corpid, corpsecret是准确的,请务必执行: group_client.is_valid?
部门
group_client.department.create(name, parent_id, order=nil) group_client.department.update(id, name, parent_id, order=nil) group_client.department.delete(id) group_client.department.list
成员
group_client.user.create(user_id, name, options={}) group_client.user.update(user_id, options={}) group_client.user.delete(user_id) group_client.user.get(user_id) group_client.user.simple_list(department_id, fetch_child=nil, status=nil)
标签
group_client.tag.create(name) group_client.tag.update(id, name) group_client.tag.delete(id) group_client.tag.get(id) group_client.tag.add_tag_users(id, user_ids) group_client.tag.delete_tag_users(id, user_ids) group_client.tag.list
自定义菜单
menu_json的生成方法请参考:
https://github.com/lanrion/weixin_rails_middleware/wiki/DIY-menu
group_client.menu.create(menu_json, app_id) group_client.menu.delete(app_id) group_client.menu.get(app_id)
Oauth2用法
先要配置你应用的 可信域名 2458023e.ngrok.com
state 为开发者自定义参数,可选
# 生成授权url group_client.oauth.authorize_url("http://2458023e.ngrok.com", "state") # 获取code后,获取用户信息 # app_id: 跳转链接时所在的企业应用ID group_client.oauth.get_user_info("code", "app_id")
发送消息
# params: (users, parties, tags, agent_id, content, safe=0) # users, parties, tags 如果是多个用户,传数组,如果是全部,则直接传 "@all" group_client.message.send_text("@all", "@all", "@all", app_id, text_message)
其他发送消息方法请查看 api/message.rb
上传多媒体文件
# params: media, media_type group_client.media.upload(image_jpg_file, "image") # 获取下载链接 # 返回一个URL,请开发者自行使用此url下载 group_client.media.get_media_by_id(media_id)
相关推荐
微信企业号推广案例介绍
微信企业号接口开发源码(Java)
最新的微信企业号应用介绍,(企业)微信企业号建设方案 ,压缩后供参考
当今社会移动互联网发展越来越快,需要建立相应 的移动管理系统来加强对移动...本文主要探讨利用微信企业号搭建企 业移动管理平台的实践与探索。通过不断的探索与实践为企 业建立一个更加安全的移动信息管理系统。
微信公众平台企业号PHP-SDK, 官方API类库,微信企业号开发SDK
微信企业号推广建设方案
微信公众平台企业号PHP-SDK, 官方API类库,微信企业号开发SDK
原创首发微信企业号二次验证接口PHP代码
关于微信企业号的申请流程,希望对大家有帮助。
微信企业号主动推送消息,接受消息及自动回复。 定时获取TOKEN;定时自动从数据库获取依次把消息发送出去。发送失败后再次发送,直到发送成功。代码已经过多次测试
用C#开发的微信企业号群发工具,可以发送文字信息、图文信息等,下载了直接用就可以。 测试时需要修改下一配置文件。 <!--CorpId 企业id--> <!--corpsecret 管理组的凭证密钥--> <!--agentid ...
根据微信官方C#加解密库改写成适用于asp.net的回调模式验证 Cryptography.vb文件封装了AES加解密过程。 WXBizMsgCrypt.vb文件提供了用户接入企业微信的接口。 Sample.aspx.vb文件提供了回调验证的示例。
c#winform开发微信企业号推送文本消息,图片,图文,视频,语音等消息
微企移动OA系统(以下简称为本系统)是基于微信企业号,借用微信平台而建立的移动办公系统。企业用户不需要下载安装APP,只需打开微信扫描二维码关注,即可实现移动协同办公,不局限于电脑PC端,让办公移到手机、...
C#实现微信企业号API服务端调用封装全部源码 1、基础方法 1.1 在回调模式下验证服务器接口地址 1.2 服务器端解密方法 1.3 服务器端加密方法 1.4 获取AccessToken(企业号的全局唯一票据) 1.5 获取企业号应用的基本...
福田微信企业号使用手册1期.docx
c#微信企业号推送消息,亲测通过.rar
ERP应用+OA手机端+Crm源码+微信企业号接口考勤无任何限制版
c#微信企业号推送消息,亲测通过_(0601).rar
(企业)微信企业号建设方案(2020年九月整理).doc.pdf