TwitterClientApp
A simple Sinatra app which is integrated with Twitter OAuth login and some of its API.
This gem aims for Sencha MokuMoku Meetup 2nd (that be held in Japan at 2014/05/30).
Installation
Add this line to your application's Gemfile:
gem 'twitter_client_app'
And then execute:
$ bundle
Or install it yourself as:
$ gem install twitter_client_app
Usage
Create an app directory, then make Gemfile.
mkdir myapp && cd myapp && touch Gemfile
Edit Gemfile as followings.
# A sample Gemfile
source "https://rubygems.org"
gem 'twitter_client_app'
then Bundle install
.
Or you can use init
command of twitter_client_app
.
$ twitter_client_app init PROJECT_NAME
If you want to use CLI, you should install 'twitter_client_app' gem directory.
Also make public directory, and put the index.html file. After that, please make app.rb and edit it as following.
require 'twitter_client_app'
CONSUMER_KEY = "Your Consumer key"
CONSUMER_SECRET = "Your Consumer Secret"
HASH_TAG = "#sencha"
SEARCH_LIMIT = 50
TouchTweet::App.setRoot(File.(File.dirname(__FILE__)))
TouchTweet::App.run!
Put the your tweet app's consumer key and consumer secret on TouchTweet::App::CONSUMER_KEY
and TouchTweet::App::CONSUMER_SECRET
. HASH_TAG
is used for search and post a tweet. SEARCH_LIMIT
is also used to search a tweet.
That's all! After you have to do is use it. :)
$ ruby app.rb
[2014-05-17 16:21:29] INFO WEBrick 1.3.1
...
[2014-05-17 16:21:29] INFO WEBrick::HTTPServer#start: pid=96175 port=4567
You can execute twitter login function with GET /login
.
You can get tweets (it's a JSON format) from Twitter with GET /tweets
.
You can post a tweet with POST /post
.
For more information, please see the files of example
directory.
Contributing
- Fork it ( https://github.com/[my-github-username]/twitter_client_app/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