wxapi 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +45 -0
- data/Rakefile +4 -3
- data/lib/wx_api.rb +5 -2
- data/lib/wxapi/access_token.rb +2 -2
- data/lib/wxapi/account.rb +1 -1
- data/lib/wxapi/menu.rb +2 -2
- data/lib/wxapi/version.rb +1 -1
- data/test.rb +11 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 100fdf3b99ae4aeb7ddc3a7c4433c502b56048d9235590944b369a7989320729
|
4
|
+
data.tar.gz: 1af2c21175d8f63f62078b0b3944579d8af9628ef44aff78ab13f2ba3f945267
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d226b31593a1a794963ba8a6acb4820ca785c3eff1545d35e4e2233a46cd2341de4bccef98797db4727ca1d2fc0d3763291549cc015c34d9a3424d0df3e848dd
|
7
|
+
data.tar.gz: ceabcbb9eb1bb2f5535c3dc9b83b31be552a32ce5afa0c2fcd347242fe0a3095361b18165c3b330ffdd7d3d6ba804036ee3fa2138e4df448254ade1dbeb0d4ce
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
wxapi (1.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
connection_pool (2.4.1)
|
10
|
+
domain_name (0.6.20240107)
|
11
|
+
http-accept (1.7.0)
|
12
|
+
http-cookie (1.0.5)
|
13
|
+
domain_name (~> 0.5)
|
14
|
+
json (2.7.1)
|
15
|
+
mime-types (3.5.2)
|
16
|
+
mime-types-data (~> 3.2015)
|
17
|
+
mime-types-data (3.2023.1205)
|
18
|
+
netrc (0.11.0)
|
19
|
+
rake (10.5.0)
|
20
|
+
redis (5.0.8)
|
21
|
+
redis-client (>= 0.17.0)
|
22
|
+
redis-client (0.19.1)
|
23
|
+
connection_pool
|
24
|
+
rest-client (2.1.0)
|
25
|
+
http-accept (>= 1.7.0, < 2.0)
|
26
|
+
http-cookie (>= 1.0.2, < 2.0)
|
27
|
+
mime-types (>= 1.16, < 4.0)
|
28
|
+
netrc (~> 0.8)
|
29
|
+
unf_ext (0.0.7.7)
|
30
|
+
|
31
|
+
PLATFORMS
|
32
|
+
ruby
|
33
|
+
x86_64-darwin-22
|
34
|
+
|
35
|
+
DEPENDENCIES
|
36
|
+
bundler
|
37
|
+
json
|
38
|
+
rake (~> 10.0)
|
39
|
+
redis
|
40
|
+
rest-client (~> 2.1)
|
41
|
+
unf_ext (~> 0.0.7.5)
|
42
|
+
wxapi!
|
43
|
+
|
44
|
+
BUNDLED WITH
|
45
|
+
2.5.4
|
data/Rakefile
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
1
|
+
#require "bundler/gem_tasks"
|
2
2
|
task :default => :spec
|
3
3
|
|
4
4
|
|
5
5
|
task :upload do |t|
|
6
|
-
|
7
|
-
|
6
|
+
puts "Uploading not implemented"
|
7
|
+
wxApi = WxApi.new app_id: 'wx3b8fe6d36cc00e3e'
|
8
|
+
puts wxApi.get_access_token
|
8
9
|
end
|
data/lib/wx_api.rb
CHANGED
@@ -10,6 +10,9 @@ require "wxapi/user"
|
|
10
10
|
require "wxapi/material"
|
11
11
|
|
12
12
|
class WxApi
|
13
|
+
|
14
|
+
|
15
|
+
|
13
16
|
include AccessToken
|
14
17
|
include Account
|
15
18
|
include Aes
|
@@ -28,14 +31,14 @@ class WxApi
|
|
28
31
|
#
|
29
32
|
# api.get_access_token
|
30
33
|
#
|
31
|
-
|
32
34
|
attr_accessor :app_id, :app_secret, :access_token_cache
|
33
35
|
attr_accessor :prefix
|
34
36
|
def initialize(options={})
|
35
37
|
@app_id = options[:app_id]
|
36
38
|
@app_secret = options[:app_secret]
|
37
39
|
@access_token_cache = options[:access_token_cache]
|
38
|
-
@prefix = options[:
|
40
|
+
@prefix = options[:prefix]
|
39
41
|
@prefix="https://api.weixin.qq.com" if @prefix.nil?
|
40
42
|
end
|
43
|
+
|
41
44
|
end
|
data/lib/wxapi/access_token.rb
CHANGED
@@ -18,7 +18,7 @@ class WxApi
|
|
18
18
|
access_token_cache = @access_token_cache
|
19
19
|
|
20
20
|
unless access_token_cache
|
21
|
-
response =
|
21
|
+
response = RestClient.get("#{prefix}/cgi-bin/token?grant_type=client_credential&appid=#{appid}&secret=#{secret}").body
|
22
22
|
response_body = (JSON.parse response)
|
23
23
|
|
24
24
|
# 抛出异常
|
@@ -30,7 +30,7 @@ class WxApi
|
|
30
30
|
_cache_key = "#{appid}_access_token"
|
31
31
|
_cached_access_token = $redis.get _cache_key
|
32
32
|
if _cached_access_token == nil or _cached_access_token == ''
|
33
|
-
response =
|
33
|
+
response = RestClient.get("#{prefix}/cgi-bin/token?grant_type=client_credential&appid=#{appid}&secret=#{secret}").body
|
34
34
|
response_body = (JSON.parse response)
|
35
35
|
|
36
36
|
# 抛出异常
|
data/lib/wxapi/account.rb
CHANGED
data/lib/wxapi/menu.rb
CHANGED
@@ -54,7 +54,7 @@ class WxApi
|
|
54
54
|
def query_menu()
|
55
55
|
# request access_token
|
56
56
|
access_token = get_access_token()
|
57
|
-
response =
|
57
|
+
response = RestClient.get("#{prefix}/cgi-bin/menu/get?access_token=#{access_token}").body
|
58
58
|
(JSON.parse response)
|
59
59
|
end
|
60
60
|
|
@@ -65,7 +65,7 @@ class WxApi
|
|
65
65
|
def delete_menu()
|
66
66
|
# request access_token
|
67
67
|
access_token = get_access_token
|
68
|
-
response =
|
68
|
+
response = RestClient.get("#{prefix}/cgi-bin/menu/delete?access_token=#{access_token}").body
|
69
69
|
(JSON.parse response)
|
70
70
|
end
|
71
71
|
end
|
data/lib/wxapi/version.rb
CHANGED
data/test.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require './lib/wx_api'
|
2
|
+
require 'redis'
|
3
|
+
require 'rest-client'
|
4
|
+
require 'json'
|
5
|
+
$redis = Redis.new(url: "redis://localhost:6379/0")
|
6
|
+
$we_api = WxApi.new app_id: 'wx3b8fe6d36cc00e3e',
|
7
|
+
app_secret: 'e6755d03d7f58b71aac8c22f6271c265',
|
8
|
+
access_token_cache: false,
|
9
|
+
api_prefix: 'https://proxy.biying88.cn/proxywx'
|
10
|
+
|
11
|
+
puts $we_api.get_access_token
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wxapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- '黄滚 twitter: @hg_nohair'
|
@@ -103,6 +103,7 @@ extra_rdoc_files: []
|
|
103
103
|
files:
|
104
104
|
- ".gitignore"
|
105
105
|
- Gemfile
|
106
|
+
- Gemfile.lock
|
106
107
|
- LICENSE.txt
|
107
108
|
- README.md
|
108
109
|
- Rakefile
|
@@ -119,6 +120,7 @@ files:
|
|
119
120
|
- lib/wxapi/user.rb
|
120
121
|
- lib/wxapi/utils.rb
|
121
122
|
- lib/wxapi/version.rb
|
123
|
+
- test.rb
|
122
124
|
- wxapi.gemspec
|
123
125
|
homepage: https://github.com/xurenlu/wxapi
|
124
126
|
licenses:
|