README.md in blsm-mp-wx-0.1.8 vs README.md in blsm-mp-wx-0.1.9
- old
+ new
@@ -1,11 +1,17 @@
-# Blsm::Mp::Wx
+# BlsmMpWx
-Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/blsm/mp/wx`. To experiment with that code, run `bin/console` for an interactive prompt.
+首趣微店微信公众号相关,包含了获取access_token、jsapi_ticket、用户详情、二维码、长短连接转换、发送消息等。依赖于正式环境数据库。
-TODO: Delete this and the text above, and describe your gem
+### 包含的model
+```ruby
+VdMpMsg #消息通知
+VdMpWx #微信公众号基本信息
+```
+
+
## Installation
Add this line to your application's Gemfile:
```ruby
@@ -18,12 +24,103 @@
Or install it yourself as:
$ gem install blsm-mp-wx
-## Usage
+## 用法
-TODO: Write usage instructions here
+### 初始化gem
+
+
+```ruby
+#config/initializers/blsm_mp_wx.rb
+BlsmMpWx.APP_ID='you_app_id' #默认的app_id
+BlsmMpWx.APP_ID_2='another_app_id' #
+```
+
+### 获取 access_token
+
+```ruby
+ r = BlsmMpWx.access_token
+ puts "#{r}\n"
+ #=> awalk19233w123e09112ewq321as232
+```
+
+
+### 获取js_api_ticket
+
+```ruby
+ r = BlsmMpWx.js_api_ticket
+ puts "#{r}\n"
+ #=> awalk19233w123e09112ewq321as232
+```
+
+### 发送消息
+
+```ruby
+ r = BlsmMpWx.send_msg(nil, 'oOx9us4iLrID8v1MRg6KEvPXMZuY',
+ {
+ touser: "oOx9us4iLrID8v1MRg6KEvPXMZuY",
+ msgtype: "text",
+ text:
+ {
+ content: "Hello World"
+ }
+ }
+ )
+ puts "#{r}\n"
+ #=> true
+```
+
+### 获取js_api 签名
+
+```ruby
+ r = BlsmMpWx.js_api_sign_package(nil, 'http://test.wunion.4007060700.com')
+ puts "#{r}\n"
+ #=> awalk19233w123e09112ewq321as232
+```
+
+
+### 获取用户详情
+
+```ruby
+ r = BlsmMpWx.gen_wx_user_info(nil, 'oOx9us4iLrID8v1MRg6KEvPXMZuY')
+ puts "#{r}\n"
+ expect(r[:headimgurl]).to match /^http:\/\//
+```
+
+
+### 获取永久二维码
+
+```ruby
+ r = BlsmMpWx.gen_forever_qr_ticket(nil, '181')
+ puts "#{r}\n"
+ expect(r).to match /\w{30,100}/
+```
+
+
+### 长连接转短连接
+
+```ruby
+ r = BlsmMpWx.gen_short_url(nil, 'http://test.wunion.4007060700.com')
+ puts "#{r}\n"
+ expect(r).to match /^http:\/\//
+```
+
+### 将消息添加到队列
+
+```ruby
+ msg_content = {touser: 'ogcP4jvEx22o_BsFu03g95jHcQqw',
+ order_id: 'cd94ac361215014072b83064a356812c',
+ msg_to: 'buyer'}
+ # r = BlsmMpWx.create_msg(nil, 'oOx9us4iLrID8v1MRg6KEvPXMZuY', msg_content, 'score_change')
+ r = BlsmMpWx.create_msg('wx75766c8f4f06701f', msg_content[:touser], msg_content, 'new_order')
+ msg_content[:msg_to]='seller'
+ msg_content[:touser]='oOx9us4iLrID8v1MRg6KEvPXMZuY'
+ r = BlsmMpWx.create_msg(nil, msg_content[:touser], msg_content, 'new_order')
+ puts "#{r.inspect}\n"
+ expect(r.id>0).to eq(true)
+```
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.