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
1afe8f3b
Commit
1afe8f3b
authored
Aug 15, 2015
by
lanrion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加获取客服聊天记录接口
parent
1e7e29a7
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
4 deletions
+38
-4
README.md
+1
-0
lib/weixin_authorize.rb
+12
-4
lib/weixin_authorize/api/custom.rb
+18
-0
spec/api/custom_spec.rb
+7
-0
No files found.
README.md
View file @
1afe8f3b
...
...
@@ -25,6 +25,7 @@ Support using [Redis](http://redis.io) to store `access_token`
*
群发消息
*
多媒体管理
*
JS SDK(ticket支持缓存)
*
更多请查看测试例子
## V2.0开发中:
https://github.com/lanrion/weixin_authorize/milestones/v2.0-dev
...
...
lib/weixin_authorize.rb
View file @
1afe8f3b
...
...
@@ -27,9 +27,12 @@ module WeixinAuthorize
autoload
(
:RedisStore
,
"weixin_authorize/js_ticket/redis_store"
)
end
OK_MSG
=
"ok"
OK_CODE
=
0
GRANT_TYPE
=
"client_credential"
OK_MSG
=
"ok"
.
freeze
OK_CODE
=
0
.
freeze
GRANT_TYPE
=
"client_credential"
.
freeze
# 用于标记endpoint可以直接使用url作为完整请求API
CUSTOM_ENDPOINT
=
"custom_endpoint"
.
freeze
class
<<
self
...
...
@@ -40,7 +43,10 @@ module WeixinAuthorize
def
http_post_without_token
(
url
,
payload
=
{},
headers
=
{},
endpoint
=
"plain"
)
post_api_url
=
endpoint_url
(
endpoint
,
url
)
payload
=
JSON
.
dump
(
payload
)
if
endpoint
==
"plain"
# to json if invoke "plain"
# to json if invoke "plain"
if
endpoint
==
"plain"
||
endpoint
==
CUSTOM_ENDPOINT
payload
=
JSON
.
dump
(
payload
)
end
load_json
(
resource
(
post_api_url
).
post
(
payload
,
params:
headers
))
end
...
...
@@ -57,6 +63,8 @@ module WeixinAuthorize
end
def
endpoint_url
(
endpoint
,
url
)
# 此处为了应对第三方开发者如果自助对接接口时,URL不规范的情况下,可以直接使用URL当为endpoint
return
url
if
endpoint
==
CUSTOM_ENDPOINT
send
(
"
#{
endpoint
}
_endpoint"
)
+
url
end
...
...
lib/weixin_authorize/api/custom.rb
View file @
1afe8f3b
...
...
@@ -108,6 +108,24 @@ module WeixinAuthorize
http_post
(
custom_base_url
,
message
)
end
# 官方示例:{endtime: 1439571890, pageindex: 1, pagesize: 10, starttime: 1438707864}
# options:
# page_index: 查询第几页,从1开始
# page_size: 每页大小,每页最多拉取50条
CUSTOM_RECORD_URL
=
"https://api.weixin.qq.com/customservice/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
page_size
=
options
[
:page_size
]
||
50
option
=
{
endtime:
end_time
,
starttime:
start_time
,
pageindex:
page_index
,
pagesize:
page_size
}
http_post
(
CUSTOM_RECORD_URL
,
option
,
{},
WeixinAuthorize
::
CUSTOM_ENDPOINT
)
end
private
# https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN
...
...
spec/api/custom_spec.rb
View file @
1afe8f3b
...
...
@@ -52,4 +52,11 @@ describe WeixinAuthorize::Api::Custom do
pending
(
"The test must have a media_id"
)
end
it
"#get_custom_msg_record"
do
option
=
{
pageindex:
1
,
pagesize:
10
}
response
=
$client
.
get_custom_msg_record
(
Time
.
now
-
10
.
days
,
Time
.
now
,
option
)
expect
(
response
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
expect
(
response
.
result
.
keys
).
to
eq
([
"recordlist"
,
"retcode"
])
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