https://github.com/andrew/twitter

A Ruby interface to the Twitter API.

https://github.com/andrew/twitter

Science Score: 10.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    2 of 166 committers (1.2%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.2%) to scientific vocabulary

Keywords from Contributors

authorization oauth2 oauth2-client oidc oidc-client
Last synced: 10 months ago · JSON representation

Repository

A Ruby interface to the Twitter API.

Basic Info
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 2
  • Open Issues: 0
  • Releases: 0
Fork of sferik/twitter-ruby
Created over 10 years ago · Last pushed over 10 years ago
Metadata Files
Readme Changelog Contributing License

README.md

The Twitter Ruby Gem

Gem Version Build Status Dependency Status Code Climate Coverage Status Inline docs

A Ruby interface to the Twitter API.

Installation

gem install twitter

CLI

Looking for the Twitter command-line interface? It was removed from this gem in version 0.5.0 and now exists as a separate project.

Documentation

http://rdoc.info/gems/twitter

Examples

https://github.com/sferik/twitter/tree/master/examples

Announcements

You should follow @gem on Twitter for announcements and updates about this library.

Mailing List

Please direct questions about this library to the mailing list.

Apps Wiki

Does your project or organization use this gem? Add it to the apps wiki!

Configuration

Twitter API v1.1 requires you to authenticate via OAuth, so you'll need to register your application with Twitter. Once you've registered an application, make sure to set the correct access level, otherwise you may see the error:

Read-only application cannot POST

Your new application will be assigned a consumer key/secret pair and you will be assigned an OAuth access token/secret pair for that application. You'll need to configure these values before you make a request or else you'll get the error:

Bad Authentication data

You can pass configuration options as a block to Twitter::REST::Client.new.

ruby client = Twitter::REST::Client.new do |config| config.consumer_key = "YOUR_CONSUMER_KEY" config.consumer_secret = "YOUR_CONSUMER_SECRET" config.access_token = "YOUR_ACCESS_TOKEN" config.access_token_secret = "YOUR_ACCESS_SECRET" end

Usage Examples

After configuring a client, you can do the following things.

Tweet (as the authenticated user)

ruby client.update("I'm tweeting with @gem!") Follow a user (by screen name or user ID)

ruby client.follow("gem") client.follow(213747670) Fetch a user (by screen name or user ID)

ruby client.user("gem") client.user(213747670) Fetch a cursored list of followers with profile details (by screen name or user ID, or by implicit authenticated user)

ruby client.followers("gem") client.followers(213747670) client.followers Fetch a cursored list of friends with profile details (by screen name or user ID, or by implicit authenticated user)

ruby client.friends("gem") client.friends(213747670) client.friends

Fetch the timeline of Tweets by a user

ruby client.user_timeline("gem") client.user_timeline(213747670) Fetch the timeline of Tweets from the authenticated user's home page

ruby client.home_timeline Fetch the timeline of Tweets mentioning the authenticated user

ruby client.mentions_timeline Fetch a particular Tweet by ID

ruby client.status(27558893223) Collect the three most recent marriage proposals to @justinbieber

ruby client.search("to:justinbieber marry me", result_type: "recent").take(3).collect do |tweet| "#{tweet.user.screen_name}: #{tweet.text}" end Find a Japanese-language Tweet tagged #ruby (excluding retweets)

ruby client.search("#ruby -rt", lang: "ja").first.text For more usage examples, please see the full documentation.

Streaming

Site Streams are restricted to whitelisted accounts. To apply for access, follow the steps in the Site Streams documentation. User Streams do not require prior approval.

Configuration works just like Twitter::REST::Client

ruby client = Twitter::Streaming::Client.new do |config| config.consumer_key = "YOUR_CONSUMER_KEY" config.consumer_secret = "YOUR_CONSUMER_SECRET" config.access_token = "YOUR_ACCESS_TOKEN" config.access_token_secret = "YOUR_ACCESS_SECRET" end

Stream a random sample of all tweets

ruby client.sample do |object| puts object.text if object.is_a?(Twitter::Tweet) end

Stream mentions of coffee or tea

ruby topics = ["coffee", "tea"] client.filter(track: topics.join(",")) do |object| puts object.text if object.is_a?(Twitter::Tweet) end

Stream tweets, events, and direct messages for the authenticated user

ruby client.user do |object| case object when Twitter::Tweet puts "It's a tweet!" when Twitter::DirectMessage puts "It's a direct message!" when Twitter::Streaming::StallWarning warn "Falling behind!" end end

An object may be one of the following: * Twitter::Tweet * Twitter::DirectMessage * Twitter::Streaming::DeletedTweet * Twitter::Streaming::Event * Twitter::Streaming::FriendList * Twitter::Streaming::StallWarning

Object Graph

Entity-relationship diagram

This entity-relationship diagram is generated programatically. If you add or remove any Twitter objects, please regenerate the ERD with the following command:

bundle exec rake erd

Supported Ruby Versions

This library aims to support and is tested against the following Ruby versions:

  • Ruby 1.9.3
  • Ruby 2.0.0
  • Ruby 2.1
  • Ruby 2.2
  • JRuby 1.7 (in Ruby 1.9 mode)

If something doesn't work on one of these versions, it's a bug.

This library may inadvertently work (or seem to work) on other Ruby versions, however support will only be provided for the versions listed above.

If you would like this library to support another Ruby version or implementation, you may volunteer to be a maintainer. Being a maintainer entails making sure all tests run and pass on that implementation. When something breaks on your implementation, you will be responsible for providing patches in a timely fashion. If critical issues for a particular implementation exist at the time of a major release, support for that Ruby version may be dropped.

Versioning

This library aims to adhere to Semantic Versioning 2.0.0. Violations of this scheme should be reported as bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, that version should be immediately yanked and/or a new version should be immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new major versions. As a result of this policy, you can (and should) specify a dependency on this gem using the Pessimistic Version Constraint with two digits of precision. For example:

spec.add_dependency 'twitter', '~> 6.0'

Copyright

Copyright (c) 2006-2015 Erik Michaels-Ober, John Nunemaker, Wynn Netherland, Steve Richert, Steve Agalloco. See LICENSE for details.

Owner

  • Name: Andrew Nesbitt
  • Login: andrew
  • Kind: user
  • Location: Bristol, UK
  • Company: @ecosyste-ms and @octobox

Working on mapping the world of open source software @ecosyste-ms and empowering developers with @octobox

GitHub Events

Total
Last Year

Committers

Last synced: 10 months ago

All Time
  • Total Commits: 2,363
  • Total Committers: 166
  • Avg Commits per committer: 14.235
  • Development Distribution Score (DDS): 0.33
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Erik Michaels-Ober s****k@g****m 1,584
John Nunemaker n****r@g****m 184
Wynn Netherland w****d@g****m 81
laserlemon s****t@g****m 50
Wynn Netherland w****n@s****m 47
Steve Agalloco s****o@g****m 42
jnunemaker j****r@f****e 39
Ryan Waldron r****w@e****m 16
Nidev Plontra n****a@g****m 12
Oliver Azevedo Barnes o****s@g****m 11
Paul Walker g****b@p****v 11
Ufuk Kayserilioglu u****k@e****m 9
Yannick Schutz y****z@g****m 8
gabrielsomoza w****k@g****m 8
Julien Nakache j****e@g****m 7
William Roe w****e@g****m 7
tomykaira t****a@g****m 7
Adam Bird a****d@g****m 5
Michael Herold m****d@g****m 5
Nathaniel Barnes k****i@g****m 5
Nikica Jokic n****a@g****m 5
Zach Moazeni z****i@g****m 5
Charlie Somerville c****e@c****m 4
David Fisher t****n@g****m 4
Kornelius Kalnbach m****y@r****e 4
Kunal Modi k****m@g****m 4
Nicolas Braem n****m@g****m 4
René Föhring rf@b****e 4
Scott Burton s****n@g****m 4
Seggy Umboh s****h@g****m 4
and 136 more...

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Dependencies

Gemfile rubygems
  • coveralls >= 0 development
  • pry >= 0 development
  • rspec >= 2.14 development
  • rubocop >= 0.27 development
  • simplecov >= 0.9 development
  • timecop >= 0 development
  • webmock >= 0 development
  • yardstick >= 0 development
  • jruby-openssl >= 0
  • rake >= 0
  • yard >= 0
twitter.gemspec rubygems
  • bundler ~> 1.0 development
  • addressable ~> 2.3
  • buftok ~> 0.2.0
  • equalizer ~> 0.0.11
  • http ~> 0.9.4
  • http-form_data ~> 1.0
  • http_parser.rb ~> 0.6.0
  • memoizable ~> 0.4.0
  • multipart-post ~> 2.0
  • naught ~> 1.0
  • simple_oauth ~> 0.3.0