Himtwiauth
Himtwiauth makes you easy to authentificate using gem (twitter)[https://github.com/sferik/twitter]
you don't have to write your API key in your code !
Installation
Add this line to your application's Gemfile:
gem 'himtwiauth'
And then execute:
$ bundle
Or install it yourself as:
$ gem install himtwiauth
Usage
please require Himtwiauth
require 'himtwiauth'
set your account, mode and path
if you want to use REST API, configuration follows
mode = 'REST'
or if you want to use Streaming API, configuration follows
mode = "Streaming"
please make password file (yaml)
# password.yaml
twitter:
screen_name : ""
consumer_key : ""
consumer_secret : ""
access_token : ""
access_token_secret : ""
for instance, your name is 'himkt', configuration follows
# password.yaml
twitter: himkt
screen_name : "example"
consumer_key : "example"
consumer_secret : "example"
access_token : "example"
access_token_secret : "example"
and your account is 'himkt'. so
account = 'himkt'
last, please specify path to your password.yaml.
for instance, if your password.yaml is on '/Users/foo/Desktop', configuration follows
path = '/Users/foo/Desktop/password.yaml'
create client instance !
client = Himtwiauth.set_client(account, mode, path)
so far, your code is similar to
require 'himtwiauth'
mode = 'REST'
account = 'himkt'
path = '/Users/foo/Desktop/password.yaml'
client = Himtwiauth.set_client(account, mode, path)
you complete authentificate !
Examples
require 'himtwiauth'
mode = 'REST'
account = 'himkt'
path = '/Users/foo/Desktop/password.yaml'
client = Himtwiauth.set_client(account, mode, path)
client.update('test')
mode = 'Streaming'
client = Himtwiauth.set_client(account, mode, path)
p client
client.filter(locations: "-122.75,36.8,-121.75,37.8") do |tweet|
puts tweet.text
end
other examples here, please see.
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.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
to create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Contributing
- Fork it ( https://github.com/[my-github-username]/himtwiauth/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