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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a96de275aacbda637fb5d2f52229cbfae165c168f7b657dd5c6608b742805e20
4
- data.tar.gz: 0e4e7d0888413af25fa4392b9f5a4b7adfabbc8782721eb6fdd900392f3f3ccc
3
+ metadata.gz: 100fdf3b99ae4aeb7ddc3a7c4433c502b56048d9235590944b369a7989320729
4
+ data.tar.gz: 1af2c21175d8f63f62078b0b3944579d8af9628ef44aff78ab13f2ba3f945267
5
5
  SHA512:
6
- metadata.gz: 6050182becc85a57cab38778ae027fe22497a26ee33366c36c95edcb1b4736cf72f5f6ff1f42421d908a4b7d907df1259430cfe1cba38a364d6c98d1816d0b08
7
- data.tar.gz: e8522ae70f8312f1cc18b039b99e51be5e5c782ff46b7b70cb7ca0a3e16a473993fbd63f248d18e284777acb316a4f93ebbad0c3f7a8976b0322a4975ebd6074
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
- sh "gem build wxapi.gemspec"
7
- sh "gem push wxapi-#{WxApi::VERSION}.gem"
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[:api_prefix]
40
+ @prefix = options[:prefix]
39
41
  @prefix="https://api.weixin.qq.com" if @prefix.nil?
40
42
  end
43
+
41
44
  end
@@ -18,7 +18,7 @@ class WxApi
18
18
  access_token_cache = @access_token_cache
19
19
 
20
20
  unless access_token_cache
21
- response = HTTParty.get("#{prefix}/cgi-bin/token?grant_type=client_credential&appid=#{appid}&secret=#{secret}").body
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 = HTTParty.get("#{prefix}/cgi-bin/token?grant_type=client_credential&appid=#{appid}&secret=#{secret}").body
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
@@ -81,7 +81,7 @@ class WxApi
81
81
  end
82
82
 
83
83
  File.open(path, 'wb') do |f|
84
- f.write(HTTParty.get(url).body)
84
+ f.write(RestClient.get(url).body)
85
85
  end
86
86
 
87
87
  path
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 = HTTParty.get("#{prefix}/cgi-bin/menu/get?access_token=#{access_token}").body
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 = HTTParty.get("#{prefix}/cgi-bin/menu/delete?access_token=#{access_token}").body
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
@@ -1,3 +1,3 @@
1
1
  class WxApi
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
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.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: