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
8e717992
Commit
8e717992
authored
Aug 15, 2015
by
lanrion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加客服接口创建会话接口
parent
cc783b25
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
2 deletions
+26
-2
lib/weixin_authorize/api/custom.rb
+21
-2
spec/api/custom_spec.rb
+5
-0
No files found.
lib/weixin_authorize/api/custom.rb
View file @
8e717992
...
...
@@ -3,6 +3,8 @@ module WeixinAuthorize
module
Api
module
Custom
CUSTOM_SERVICE
=
"https://api.weixin.qq.com/customservice"
.
freeze
# 发送文本消息
# {
# "touser":"OPENID",
...
...
@@ -112,7 +114,7 @@ module WeixinAuthorize
# options:
# page_index: 查询第几页,从1开始
# page_size: 每页大小,每页最多拉取50条
CUSTOM_RECORD_URL
=
"
https://api.weixin.qq.com/customservice
/msgrecord/getrecord"
.
freeze
CUSTOM_RECORD_URL
=
"
#{
CUSTOM_SERVICE
}
/msgrecord/getrecord"
.
freeze
def
get_custom_msg_record
(
start_time
,
end_time
,
options
=
{})
start_time
,
end_time
=
start_time
.
to_i
,
end_time
.
to_i
page_index
=
options
[
:page_index
]
||
1
...
...
@@ -123,7 +125,24 @@ module WeixinAuthorize
pageindex:
page_index
,
pagesize:
page_size
}
http_post
(
CUSTOM_RECORD_URL
,
option
,
{},
WeixinAuthorize
::
CUSTOM_ENDPOINT
)
http_post
(
CUSTOM_RECORD_URL
,
option
,
{},
CUSTOM_ENDPOINT
)
end
# 客服接口创建会话
# POST数据示例如下:
# {
# "kf_account" : "test1@test",
# "openid" : "OPENID",
# "text" : "这是一段附加信息"
# }
KF_SESSION_URL
=
"
#{
CUSTOM_SERVICE
}
/kfsession/create"
.
freeze
def
create_kf_session
(
account
,
open_id
,
text
)
post_body
=
{
kf_account:
account
,
openid:
open_id
,
text:
text
}
http_post
(
KF_SESSION_URL
,
post_body
,
{},
CUSTOM_ENDPOINT
)
end
private
...
...
spec/api/custom_spec.rb
View file @
8e717992
...
...
@@ -59,4 +59,9 @@ describe WeixinAuthorize::Api::Custom do
expect
(
response
.
result
.
keys
).
to
eq
([
"recordlist"
,
"retcode"
])
end
it
"#create_kf_session"
do
response
=
$client
.
create_kf_session
(
"test1@test"
,
ENV
[
"APPID"
],
"test kfsession"
)
expect
(
response
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
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