Commit d517381b by lanrion

Merge branch 'master' into dev

parents bee472cf 85a2b359
......@@ -16,7 +16,7 @@ https://github.com/lanrion/weixin_authorize/milestones/v2.0-dev
1. 重构API实现,调用方式
2. 对token,ticket的管理,提供第三方开发灵活者自助化
3. 尝试RestClient的使用,选择更高效的HTTP client包
3. 尝试RestClient的用,选择更高效的HTTP client包
4. 支持更多的异常处理机制
注意:查看Wiki或者源代码时,请切换对应的版本来查看。Master处于不断更新完善分支。
......
......@@ -33,9 +33,6 @@ module WeixinAuthorize
WeixinAuthorize.http_get_without_token("/sns/userinfo?access_token=#{oauth_token}&openid=#{openid}&lang=#{lang}", {}, "api")
end
private
end
end
end
\ No newline at end of file
end
......@@ -18,6 +18,24 @@ module WeixinAuthorize
http_get(followers_url, {next_openid: next_openid})
end
# 设置备注名
# http请求方式: POST(请使用https协议)
# https://api.weixin.qq.com/cgi-bin/user/info/updateremark?access_token=ACCESS_TOKEN
# POST数据格式:JSON
# POST数据例子:
# {
# "openid":"oDF3iY9ffA-hqb2vVvbr7qxf6A0Q",
# "remark":"pangzi"
# }
def update_remark(openid, remark)
update_url = "/user/info/updateremark"
payload = {
openid: openid,
remark: remark
}
http_post(update_url, payload)
end
private
def user_base_url
......
......@@ -39,6 +39,7 @@ module WeixinAuthorize
# result.result[:ok] #=> true
# result.result['ok'] #=> true
def package_result(result)
return result if !result.is_a?(Hash)
if defined?(Rails)
ActiveSupport::HashWithIndifferentAccess.new(result)
else
......
......@@ -5,14 +5,14 @@ describe WeixinAuthorize::Api::Qrcode do
it "#create_qr_scene" do
response = $client.create_qr_scene("123")
expect(response.code).to eq(WeixinAuthorize::OK_CODE)
expect(response.result.keys).to eq(["ticket", "expire_seconds"])
expect(response.result.keys).to eq(["ticket", "expire_seconds", "url"])
expect(response.result["expire_seconds"]).to eq(1800)
end
it "#create_qr_limit_scene" do
response = $client.create_qr_limit_scene("1234")
expect(response.code).to eq(WeixinAuthorize::OK_CODE)
expect(response.result.keys).to eq(["ticket"])
expect(response.result.keys).to eq(["ticket", "url"])
end
it "#return_qr_url" do
......
......@@ -20,4 +20,9 @@ describe WeixinAuthorize::Api::User do
expect(followers.code).to eq(WeixinAuthorize::OK_CODE)
expect(followers.result.keys).to eq(["total", "count", "data", "next_openid"])
end
it "can update user remark" do
user_info = $client.update_remark(ENV["OPENID"], "dylan")
expect(user_info.code).to eq(WeixinAuthorize::OK_CODE)
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment