Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
weixin_authorize
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
weixin_authorize
Commits
d517381b
Commit
d517381b
authored
Feb 11, 2015
by
lanrion
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into dev
parents
bee472cf
85a2b359
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
8 deletions
+28
-8
README.md
+1
-1
lib/weixin_authorize/api/oauth.rb
+1
-5
lib/weixin_authorize/api/user.rb
+18
-0
lib/weixin_authorize/handler/result_handler.rb
+1
-0
spec/api/qrcode_spec.rb
+2
-2
spec/api/user_spec.rb
+5
-0
No files found.
README.md
View file @
d517381b
...
@@ -16,7 +16,7 @@ https://github.com/lanrion/weixin_authorize/milestones/v2.0-dev
...
@@ -16,7 +16,7 @@ https://github.com/lanrion/weixin_authorize/milestones/v2.0-dev
1.
重构API实现,调用方式
1.
重构API实现,调用方式
2.
对token,ticket的管理,提供第三方开发灵活者自助化
2.
对token,ticket的管理,提供第三方开发灵活者自助化
3.
尝试RestClient的
使
用,选择更高效的HTTP client包
3.
尝试RestClient的
弃
用,选择更高效的HTTP client包
4.
支持更多的异常处理机制
4.
支持更多的异常处理机制
注意:查看Wiki或者源代码时,请切换对应的版本来查看。Master处于不断更新完善分支。
注意:查看Wiki或者源代码时,请切换对应的版本来查看。Master处于不断更新完善分支。
...
...
lib/weixin_authorize/api/oauth.rb
View file @
d517381b
...
@@ -33,9 +33,6 @@ module WeixinAuthorize
...
@@ -33,9 +33,6 @@ module WeixinAuthorize
WeixinAuthorize
.
http_get_without_token
(
"/sns/userinfo?access_token=
#{
oauth_token
}
&openid=
#{
openid
}
&lang=
#{
lang
}
"
,
{},
"api"
)
WeixinAuthorize
.
http_get_without_token
(
"/sns/userinfo?access_token=
#{
oauth_token
}
&openid=
#{
openid
}
&lang=
#{
lang
}
"
,
{},
"api"
)
end
end
private
end
end
end
end
end
end
\ No newline at end of file
lib/weixin_authorize/api/user.rb
View file @
d517381b
...
@@ -18,6 +18,24 @@ module WeixinAuthorize
...
@@ -18,6 +18,24 @@ module WeixinAuthorize
http_get
(
followers_url
,
{
next_openid:
next_openid
})
http_get
(
followers_url
,
{
next_openid:
next_openid
})
end
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
private
def
user_base_url
def
user_base_url
...
...
lib/weixin_authorize/handler/result_handler.rb
View file @
d517381b
...
@@ -39,6 +39,7 @@ module WeixinAuthorize
...
@@ -39,6 +39,7 @@ module WeixinAuthorize
# result.result[:ok] #=> true
# result.result[:ok] #=> true
# result.result['ok'] #=> true
# result.result['ok'] #=> true
def
package_result
(
result
)
def
package_result
(
result
)
return
result
if
!
result
.
is_a?
(
Hash
)
if
defined?
(
Rails
)
if
defined?
(
Rails
)
ActiveSupport
::
HashWithIndifferentAccess
.
new
(
result
)
ActiveSupport
::
HashWithIndifferentAccess
.
new
(
result
)
else
else
...
...
spec/api/qrcode_spec.rb
View file @
d517381b
...
@@ -5,14 +5,14 @@ describe WeixinAuthorize::Api::Qrcode do
...
@@ -5,14 +5,14 @@ describe WeixinAuthorize::Api::Qrcode do
it
"#create_qr_scene"
do
it
"#create_qr_scene"
do
response
=
$client
.
create_qr_scene
(
"123"
)
response
=
$client
.
create_qr_scene
(
"123"
)
expect
(
response
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
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
)
expect
(
response
.
result
[
"expire_seconds"
]).
to
eq
(
1800
)
end
end
it
"#create_qr_limit_scene"
do
it
"#create_qr_limit_scene"
do
response
=
$client
.
create_qr_limit_scene
(
"1234"
)
response
=
$client
.
create_qr_limit_scene
(
"1234"
)
expect
(
response
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
expect
(
response
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
expect
(
response
.
result
.
keys
).
to
eq
([
"ticket"
])
expect
(
response
.
result
.
keys
).
to
eq
([
"ticket"
,
"url"
])
end
end
it
"#return_qr_url"
do
it
"#return_qr_url"
do
...
...
spec/api/user_spec.rb
View file @
d517381b
...
@@ -20,4 +20,9 @@ describe WeixinAuthorize::Api::User do
...
@@ -20,4 +20,9 @@ describe WeixinAuthorize::Api::User do
expect
(
followers
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
expect
(
followers
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
expect
(
followers
.
result
.
keys
).
to
eq
([
"total"
,
"count"
,
"data"
,
"next_openid"
])
expect
(
followers
.
result
.
keys
).
to
eq
([
"total"
,
"count"
,
"data"
,
"next_openid"
])
end
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
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment