Twitter Web Intents provides simple helper methods that return Twitter Web Intent URLs. The parameters that are passed are verified to ensure they are valid.
You can read more about Twitter Web Intents on Twitter's site: https://dev.twitter.com/docs/intents
Add this line to your application's Gemfile:
gem 'twitter_web_intents'
And then execute:
$ bundle
Or install it yourself as:
$ gem install twitter_web_intents
Note: You must be using Ruby 1.9.3 or later to use this gem due to the ActiveSupport dependency.
TwitterWebIntents.get_search_url('Parmigiano-Reggiano')
#=> "https://twitter.com/search?q=Parmigiano-Reggiano"
TwitterWebIntents.get_profile_url('warblealerts')
#=> "https://twitter.com/warblealerts
TwitterWebIntents.get_status_url('warblealerts', 318705541666988034)
#=> "https://twitter.com/warblealerts/status/318705541666988034"
Valid parameters: [:screen_name, :user_id]
TwitterWebIntents.get_user_url({:screen_name => 'warblealerts'})
#=> "https://twitter.com/intent/user?screen_name=warblealerts"
OR
TwitterWebIntents.get_user_url({:user_id => 102})
#=> https://twitter.com/intent/user/?user_id=102
Valid parameters: [:tweet_id, :related]
TwitterWebIntents.get_favorite_url({:tweet_id => 318705541666988034, :related => ['warblealerts','richhollis']})
#=> "https://twitter.com/intent/favorite?related=warblealerts%2Crichhollis&tweet_id=318705541666988034"
Valid parameters: [:url, :via, :text, :in_reply_to, :hashtags, :related]
TwitterWebIntents.get_tweet_url({:url => 'http://warble.co', :via => 'richhollis', :text => 'hello world', :in_reply_to => 318705541666988034, :hashtags => '#warble', :related => 'warblealerts'})
#=> "https://twitter.com/intent/tweet?hashtags=%23warble&in_reply_to=318705541666988034&related=warblealerts&text=hello+world&url=http%3A%2F%2Fwarble.co&via=richhollis"
Valid parameters: [:tweet_id, :related]
TwitterWebIntents.get_retweet_url({:tweet_id => 318705541666988034, :related => ['warblealerts','richhollis']})
#=> "https://twitter.com/intent/retweet?related=warblealerts%2Crichhollis&tweet_id=318705541666988034"
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes and ensure test coverage (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request