https://github.com/linjunpop/weixin_js_sdk
a Weixin(Wechat) JS-SDK Toolkit.
https://github.com/linjunpop/weixin_js_sdk
wechat weixin
Last synced: about 1 year ago
JSON representation
a Weixin(Wechat) JS-SDK Toolkit.
- Host: GitHub
- URL: https://github.com/linjunpop/weixin_js_sdk
- Owner: linjunpop
- License: mit
- Created: 2015-01-26T10:07:28.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-12-16T08:43:32.000Z (over 10 years ago)
- Last Synced: 2025-04-18T22:49:43.246Z (over 1 year ago)
- Topics: wechat, weixin
- Language: Ruby
- Homepage:
- Size: 175 KB
- Stars: 15
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# WeixinJsSdk
[](https://codeclimate.com/github/linjunpop/weixin_js_sdk)
[](https://rubygems.org/gems/weixin_js_sdk)
[](http://linjunpop.mit-license.org)
a Weixin [JS-SDK](http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html) toolkit.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'weixin_js_sdk'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install weixin_js_sdk
## Usage
* Fetch Access Token
```ruby
access_token = WeixinJsSDK::AccessToken.new(
app_id: ENV['WEIXIN_APP_ID'],
app_secret: ENV['WEIXIN_APP_SECRET']
)
#=> #
access_token.token
#=> xxx
access_token.expires_in
#=> 7200
```
* Fetch Ticket
```ruby
ticket = WeixinJsSDK::Ticket.new(access_token: access_token.token)
#=> #
ticket.token
#=> xxx
ticket.expires_in
#=> 7200
```
* Generate Signature
```ruby
signature = WeixinJsSDK::Signature.new(
ticket: ticket.token,
nonce_str: 'Wm3WZYTPz0wzccnW',
timestamp: '1414587457',
url: 'http://mp.weixin.qq.com'
).sign
#=> f4d90daf4b3bca3078ab155816175ba34c443a7b
```
## Contributing
1. Fork it ( https://github.com/[my-github-username]/weixin_js_sdk/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request