Baidu::Push::Client
A simple REST client for baidu push
Installation
Add this line to your application's Gemfile:
gem 'baidu-push', github: 'scorix/baidu-push'
And then execute:
$ bundle
Usage
# build a baidu message
msg = Baidu::Push::Message.new msg_keys: "#{Time.now.to_i}_test", user_id: 'userid'
msg. = {title: 'test', description: 'test', custom_content: {}}
# new a client instance
client = Baidu::Push::Client.setup api_key: 'YOUR_API_KEY', secret_key: 'YOUR_SECRET_KEY'
client.push_msg(msg)
Or, you can also push the message with an async way
# build a baidu message
msg = Baidu::Push::Message.new msg_keys: "#{Time.now.to_i}_test", user_id: 'userid'
msg. = {title: 'test', description: 'test', custom_content: {}}
# new a client instance
client = Baidu::Push::AsyncClient.setup api_key: 'YOUR_API_KEY', secret_key: 'YOUR_SECRET_KEY'
client.async.push_msg(msg)
Contributing
- Fork it ( https://github.com/scorix/baidu-push/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request