eric_weixin 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/eric_weixin.iml +22 -0
- data/.idea/misc.xml +5 -0
- data/.idea/modules.xml +9 -0
- data/.idea/scopes/scope_settings.xml +5 -0
- data/.idea/vcs.xml +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/eric_weixin.gemspec +24 -0
- data/lib/eric_weixin/reply_message.rb +87 -0
- data/lib/eric_weixin/version.rb +3 -0
- data/lib/eric_weixin.rb +6 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bfd1ad73e2c07c9614f92be9fc53ced6059859e9
|
4
|
+
data.tar.gz: 7658834815335b3723186e52f0546787736de194
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 84bf69956c75342322bd1f7e0069a33a68a9440a04003b2f9c9aed9407964864cc66f4d534fbdb5e12a8c3348c209d95610cdc1b21581aa937475482b5de43cd
|
7
|
+
data.tar.gz: 7e6571b876eea85d559b0ca791e8ae1d5c9addde8f8f09e0543aa23dc41ce8be2f6ca57440448c9c3f9d43c53da5073e2648cf865ee661c15e77c80ec1220185
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.idea/encodings.xml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="CompassSettings">
|
4
|
+
<option name="compassSupportEnabled" value="true" />
|
5
|
+
</component>
|
6
|
+
<component name="FacetManager">
|
7
|
+
<facet type="gem" name="Ruby Gem">
|
8
|
+
<configuration>
|
9
|
+
<option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
|
10
|
+
<option name="GEM_APP_TEST_PATH" value="" />
|
11
|
+
<option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
|
12
|
+
</configuration>
|
13
|
+
</facet>
|
14
|
+
</component>
|
15
|
+
<component name="NewModuleRootManager">
|
16
|
+
<content url="file://$MODULE_DIR$" />
|
17
|
+
<orderEntry type="inheritedJdk" />
|
18
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
19
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.6.2, RVM: ruby-2.0.0-p481) [gem]" level="application" />
|
20
|
+
</component>
|
21
|
+
</module>
|
22
|
+
|
data/.idea/misc.xml
ADDED
data/.idea/modules.xml
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ProjectModuleManager">
|
4
|
+
<modules>
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/eric_weixin.iml" filepath="$PROJECT_DIR$/.idea/eric_weixin.iml" />
|
6
|
+
</modules>
|
7
|
+
</component>
|
8
|
+
</project>
|
9
|
+
|
data/.idea/vcs.xml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 刘晓琦
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# EricWeixin
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'eric_weixin'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install eric_weixin
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/eric_weixin/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/eric_weixin.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'eric_weixin/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "eric_weixin"
|
8
|
+
spec.version = EricWeixin::VERSION
|
9
|
+
spec.authors = ["刘晓琦"]
|
10
|
+
spec.email = ["ericliu@ikidstv.com"]
|
11
|
+
spec.summary = %q{微信插件}
|
12
|
+
spec.description = %q{微信插件}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency 'nokogiri'
|
24
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module EricWeixin
|
2
|
+
module ReplyMessage
|
3
|
+
##
|
4
|
+
#根据from_user, to_user等信息来获取<em>多客服</em>的数据格式
|
5
|
+
#===参数说明
|
6
|
+
# #
|
7
|
+
def self.get_customer_service_message options
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
# 获取<b>被动回复</b>消息的数据格式--类型为:<b>图文消息</b>
|
12
|
+
# 一般用于用户发消息后,使用返回消息的方式向用户进行图文回复。
|
13
|
+
# ===参数说明
|
14
|
+
# * ToUserName: 收取方的账号
|
15
|
+
# * FromUserName: 开发者账号
|
16
|
+
# * news: 文章列表,Weixin::Article 的实例数组
|
17
|
+
# ===示例
|
18
|
+
# Tools::Weixin::ReplyMessage::get_reply_user_message_image_text ToUserName: 'xx',
|
19
|
+
# FromUserName: 'yy',
|
20
|
+
# news:[Weixin::ArticleData.new]
|
21
|
+
def self.get_reply_user_message_image_text options
|
22
|
+
xml = Nokogiri::XML::Builder.new(:encoding => 'utf-8') do |xml|
|
23
|
+
xml.send(:xml) {
|
24
|
+
xml.ToUserName { xml.cdata options[:ToUserName] }
|
25
|
+
xml.FromUserName { xml.cdata options[:FromUserName] }
|
26
|
+
xml.CreateTime { xml.cdata Time.now.to_i }
|
27
|
+
xml.MsgType { xml.cdata 'news' }
|
28
|
+
xml.ArticleCount (options[:news]||[]).length
|
29
|
+
xml.Articles {
|
30
|
+
options[:news].each do |news|
|
31
|
+
xml.item {
|
32
|
+
xml.Title{xml.cdata news.title}
|
33
|
+
xml.Description{xml.cdata news.desc}
|
34
|
+
xml.PicUrl{xml.cdata news.pic_url}
|
35
|
+
xml.Url{xml.cdata news.link_url}
|
36
|
+
}
|
37
|
+
end
|
38
|
+
}
|
39
|
+
}
|
40
|
+
end
|
41
|
+
xml.to_xml
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
# 获取<b>被动回复</b>消息的数据格式--类型为:<b>文本消息</b>
|
46
|
+
# 一般用于用户发消息后,使用返回消息的方式向用户进行图文回复。
|
47
|
+
# ===参数说明
|
48
|
+
# * ToUserName: 收取方的账号
|
49
|
+
# * FromUserName: 开发者账号
|
50
|
+
# * Content: 回复的消息内容
|
51
|
+
# ===示例
|
52
|
+
# Tools::Weixin::ReplyMessage.get_reply_user_message_text ToUserName: 'xx',
|
53
|
+
# FromUserName: 'yy',
|
54
|
+
# Content: 'haha'
|
55
|
+
def self.get_reply_user_message_text options
|
56
|
+
xml = Nokogiri::XML::Builder.new(:encoding => 'utf-8') do |xml|
|
57
|
+
xml.send(:xml) {
|
58
|
+
xml.CreateTime { xml.cdata Time.now.to_i }
|
59
|
+
xml.MsgType { xml.cdata 'text' }
|
60
|
+
xml.ToUserName { xml.cdata options[:ToUserName] }
|
61
|
+
xml.FromUserName { xml.cdata options[:FromUserName] }
|
62
|
+
xml.Content { xml.cdata options[:Content] }
|
63
|
+
}
|
64
|
+
end
|
65
|
+
xml.to_xml
|
66
|
+
end
|
67
|
+
|
68
|
+
# 用于将消息转发至多客户客户端。
|
69
|
+
# ===参数说明
|
70
|
+
# * ToUserName: 收取方的账号
|
71
|
+
# * FromUserName: 开发者账号
|
72
|
+
# ===示例
|
73
|
+
# Tools::Weixin::ReplyMessage::transfer_mult_customer_service ToUserName: 'xxx',
|
74
|
+
# FromUserName: 'yyyy',
|
75
|
+
def self.transfer_mult_customer_service options
|
76
|
+
xml = Nokogiri::XML::Builder.new(:encoding => 'utf-8') do |xml|
|
77
|
+
xml.send(:xml) {
|
78
|
+
xml.CreateTime { xml.cdata Time.now.to_i }
|
79
|
+
xml.MsgType { xml.cdata 'transfer_customer_service' }
|
80
|
+
xml.ToUserName { xml.cdata options[:ToUserName] }
|
81
|
+
xml.FromUserName { xml.cdata options[:FromUserName] }
|
82
|
+
}
|
83
|
+
end
|
84
|
+
xml.to_xml
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
data/lib/eric_weixin.rb
ADDED
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: eric_weixin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- 刘晓琦
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nokogiri
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: 微信插件
|
56
|
+
email:
|
57
|
+
- ericliu@ikidstv.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- .idea/encodings.xml
|
64
|
+
- .idea/eric_weixin.iml
|
65
|
+
- .idea/misc.xml
|
66
|
+
- .idea/modules.xml
|
67
|
+
- .idea/scopes/scope_settings.xml
|
68
|
+
- .idea/vcs.xml
|
69
|
+
- Gemfile
|
70
|
+
- LICENSE.txt
|
71
|
+
- README.md
|
72
|
+
- Rakefile
|
73
|
+
- eric_weixin.gemspec
|
74
|
+
- lib/eric_weixin.rb
|
75
|
+
- lib/eric_weixin/reply_message.rb
|
76
|
+
- lib/eric_weixin/version.rb
|
77
|
+
homepage: ''
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.2.2
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: 微信插件
|
101
|
+
test_files: []
|