Mingle makes it really easy to syndicate tweets from Twitter and photos from Instagram in your Ruby on Rails application.
Add this line to your application's Gemfile:
gem 'mingle'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mingle
Install the migrations:
rake mingle:install:migrations
Run the migrations:
rake db:migrate
# Create some hashtags to syndicate content from
Mingle::Hashtag.create tag_name: "#hyper"
# Fetch tweets from Twitter
Mingle::Twitter.fetch
# Fetch photos from Instagram
Mingle::Instagram.fetch
Mingle also ships with rake tasks:
$ rake mingle:twitter:fetch
$ rake mingle:instagram:fetch
Mingle ships with Sidekiq jobs for your perusal.
Mingle is configured through Mingle.configure
, like this:
Mingle.configure do |config|
config.twitter_api_key = ENV['TWITTER_API_KEY']
# ...
end
You can also configure it temporarily:
Mingle.temporarily twitter_api_key: 'ABC123' do
# ...
end
The following configurations can be made through Mingle.configure
:
twitter_api_key
- A Twitter application's API key.twitter_api_secret
- A Twitter application's API secret.twitter_access_token
- A Twitter application's access token.twitter_access_token_secret
- A Twitter application's access token secret.instagram_client_id
- An Instagram application's client id.twitter_reject_words
- An array of words which will prevent a tweet from being imported.twitter_reject_users
- An array of Twitter user names whose tweets will not be imported.instagram_reject_words
- An array of words which will prevent an Instagram photo from being imported.instagram_reject_users
- An array of Instagram user names whose Instagram photos will not be imported.since
- A date before which posts, tweets and photos will be ignored.
Note: We recommend you store your application configuration in your
environment, like in the example above. In fact, we recommend it so much that
Mingle will automatically look for environment variables with specific names,
unless you configure them through Mingle.configure
.
Mingle checks for following environment variables by default:
TWITTER_API_KEY
- the equivalent oftwitter_api_key
TWITTER_API_SECRET
- the equivalent oftwitter_api_secret
TWITTER_ACCESS_TOKEN
- the equivalent oftwitter_access_token
TWITTER_ACCESS_TOKEN_SECRET
- the equivalent oftwitter_access_token_secret
INSTAGRAM_CLIENT_ID
- the equivalent ofinstagram_client_id
- Fork it
- 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 new Pull Request
Hyper made this. We're a digital communications agency with a passion for good code, and if you're using this library we probably want to hire you.
Mingle is available under the MIT license. See the LICENSE file for more info.