Skip to content

Commit

Permalink
New command line to generate OAuth2 URL.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Guo committed Dec 17, 2015
1 parent 9af4eff commit 7c81271
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ Wechat commands:
wechat menu # 当前菜单
wechat menu_create [MENU_YAML_PATH] # 创建菜单
wechat menu_delete # 删除菜单
wechat oauth2_url [REDIRECT_URI] # 生成OAuth2.0验证URL
wechat qrcode_create_limit_scene [SCENE_ID_OR_STR] # 请求永久二维码
wechat qrcode_create_scene [SCENE_ID, EXPIRE_SECONDS] # 请求临时二维码
wechat qrcode_download [TICKET, QR_CODE_PIC_PATH] # 通过ticket下载二维码
Expand Down Expand Up @@ -241,6 +242,7 @@ Wechat commands:
wechat menu_create [MENU_YAML_PATH] # 创建菜单
wechat menu_delete # 删除菜单
wechat message_send [OPENID, TEXT_MESSAGE] # 发送文字消息
wechat oauth2_url [REDIRECT_URI] # 生成OAuth2.0验证URL
wechat qrcode_download [TICKET, QR_CODE_PIC_PATH] # 通过ticket下载二维码
wechat tag [TAG_ID] # 获取标签成员
wechat tag_add_department [TAG_ID, PARTY_IDS] # 增加标签部门
Expand Down
8 changes: 8 additions & 0 deletions bin/wechat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require 'active_support/json'
require 'fileutils'
require 'yaml'
require 'wechat/api_loader'
require 'cgi'

class App < Thor
package_name 'Wechat'
Expand Down Expand Up @@ -284,6 +285,13 @@ class App < Thor
puts wechat_api.user(open_id)
end

desc 'oauth2_url [REDIRECT_URI]', '生成OAuth2.0验证URL'
def oauth2_url(redirect_uri)
redirect_uri = CGI.escape(redirect_uri)
appid = Wechat.config.corpid || Wechat.config.appid
puts "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{appid}&redirect_uri=#{redirect_uri}&response_type=code&scope=snsapi_base#wechat_redirect"
end

desc 'user_update_remark [OPEN_ID, REMARK]', '设置备注名'
def user_update_remark(openid, remark)
puts wechat_api.user_update_remark(openid, remark)
Expand Down

0 comments on commit 7c81271

Please sign in to comment.