DescriptionA Ruby interface to the Twitter API.
Open issues153
Last push12/6/2021 11:24:10 AM +00:00
Github URLhttps://github.com/sferik/twitter
Clone URLhttps://github.com/sferik/twitter.git
SSH URL[email protected]:sferik/twitter.git

Most active issues

Topic# Comments
Assuming this got fixed in #479 and reared its head due to some other issue now.

I literally only installed ruby 2.4, then did gem install t, and this is what happened.


/var/lib/gems/2.4.0/gems/t-3.1.0/lib/t/cli.rb:82:in `authorize': uninitialized constant Twitter::REST::Client::BASE_URL (NameError)
from /var/lib/gems/2.4.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
from /var/lib/gems/2.4.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
from /var/lib/gems/2.4.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
from /var/lib/gems/2.4.0/gems/thor-0.20.0/lib/thor/base.rb:466:in `start'
from /var/lib/gems/2.4.0/gems/t-3.1.0/bin/t:20:in `'
from /usr/local/bin/t:23:in `load'
from /usr/local/bin/t:23:in `

`gem list` says:

*** LOCAL GEMS ***

addressable (2.5.2)
bigdecimal (1.3.2, default: 1.3.0)
buftok (0.2.0)
domain_name (0.5.20170404)
equalizer (0.0.11)
geokit (1.11.0)
htmlentities (4.3.4)
http (3.0.0)
http-cookie (1.0.3)
http-form_data (2.0.0)
http_parser.rb (0.6.0)
io-console (default: 0.4.6)
json (2.1.0, default: 2.0.4)
launchy (2.4.3)
memoizable (0.4.2)
multipart-post (2.0.0)
naught (1.1.0)
oauth (0.5.3)
openssl (2.0.6, default: 2.0.5)
psych (2.2.4, default: 2.2.2)
public_suffix (3.0.1)
rdoc (5.1.0, default: 5.0.0)
retryable (2.0.4)
simple_oauth (0.3.1)
t (3.1.0)
thor (0.20.0)
thread_safe (0.3.6)
twitter (6.2.0)
unf (0.1.4)
unf_ext (

Not sure how to progress. Workarounds?

Read comments
in a `rails c` session in an app with the Twitter gem configured with my keys

1.9.3p392 :111 > thetweets = Twitter.search('git', :count => 10, :lang => "en", :result_type => "recent")
=> #[{:metadata=>{:result_type=>"recent", :iso_language_code=>"en"}, :created_at=>"Wed Mar 20 02:34:16 +0000 2013", :id=>314203204525125633, :id_str=>"314203204525125633", :text=>"@LGwenn :D Let's git this thing done!", :source=>"MetroTwit", :truncated=>false,

but a nearly identical request gets very different results:

1.9.3p392 :168 > thetweets = Twitter.search('1git', :count => 10, :lang => "en", :result_type => "recent")
**Twitter::Error::ClientError: end of file reached**
from /Users/bob/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/openssl/buffering.rb:174:in `sysread_nonblock'
from /Users/bob/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/openssl/buffering.rb:174:in `read_nonblock'
from /Users/bob/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/protocol.rb:141:in `rbuf_fill'
from /Users/bob/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil'
from /Users/bob/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/protocol.rb:132:in `readline'
from /Users/bob/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/http.rb:2770:in `read_chunked'
from /Users/bob/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/http.rb:2750:in `read_body_0'
from /Users/bob/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/http.rb:2710:in `read_body'
from /Users/bob/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/http.rb:1029:in `block in get'
from /Users/bob/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/http.rb:1322:in `block (2 levels) in transport_request'
from /Users/bob/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/http.rb:2671:in `reading_body'
from /Users/bob/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/http.rb:1321:in `block in transport_request'
from /Users/bob/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/http.rb:1316:in `catch'
from /Users/bob/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/http.rb:1316:in `transport_request'
from /Users/bob/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/http.rb:1293:in `request'
from /Users/bob/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/http.rb:1286:in `block in request'
... 8 levels...
from /Users/bob/.rvm/gems/[email protected]/gems/faraday-0.8.6/lib/faraday/request/url_encoded.rb:14:in `call'
from /Users/bob/.rvm/gems/[email protected]/gems/faraday-0.8.6/lib/faraday/request/multipart.rb:13:in `call'
from /Users/bob/.rvm/gems/[email protected]/gems/twitter-4.6.1/lib/twitter/request/multipart_with_file.rb:14:in `call'
from /Users/bob/.rvm/gems/[email protected]/gems/faraday-0.8.6/lib/faraday/connection.rb:247:in `run_request'
from /Users/bob/.rvm/gems/[email protected]/gems/faraday-0.8.6/lib/faraday/connection.rb:100:in `get'
from /Users/bob/.rvm/gems/[email protected]/gems/twitter-4.6.1/lib/twitter/client.rb:81:in `request'
from /Users/bob/.rvm/gems/[email protected]/gems/twitter-4.6.1/lib/twitter/client.rb:64:in `get'
from /Users/bob/.rvm/gems/[email protected]/gems/twitter-4.6.1/lib/twitter/api/utils.rb:82:in `object_from_response'
from /Users/bob/.rvm/gems/[email protected]/gems/twitter-4.6.1/lib/twitter/api/search.rb:32:in `search'
from /Users/bob/.rvm/gems/[email protected]/gems/twitter-4.6.1/lib/twitter.rb:52:in `method_missing'
from (irb):168
from /Users/bob/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in `start'
from /Users/bob/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in `start'
from /Users/bob/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/commands.rb:41:in `'
from script/rails:6:in `require'
from script/rails:6:in `
'1.9.3p392 :169 >

What is Twitter::Error::ClientError: end of file reached?

Read comments
Just getting started but wanted to enumerate the priorities. I'm sure I'm missing a few but here's some things that I think should be on the punchlist:
- [ ] exponential back-off reconnects as defined under [Reconnecting](https://dev.twitter.com/streaming/overview/connecting) section of Twitter docs
- [x] site stream [controls](https://dev.twitter.com/streaming/sitestreams/controlstreams)
- [ ] update and reconnect (see #565)
- [ ] 100% c0 code coverage for streaming
- [x] additional message support (see #649)

Read comments
In version 5.2.0 of the gem, marshaling tweets, users, and other objects that inherit from `Twitter::Identity` raises an exception, which makes certain things difficult, like storing them in `Rails.cache`.

Here's a simple example to reproduce the exception:

require 'twitter'

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"

tweet = client.user_timeline('gem').first
# => TypeError: no _dump_data is defined for class Proc

This commit defines `marshal_dump` and `marshal_load` for the `Twitter::Identity` class. Unfortunately, the test I wrote doesn't fail without those methods because `rspec-mocks` redefines `Marshal.load`. So any feedback on how to write a better test (or on the pull request in general) would be appreciated.

Read comments
Getting this error Twitter::Error::ClientError: execution expired often & often

Read comments
The `Twitter::NullObject` is tricky and hard to reason about. I ask that you replace its uses with a plain `nil`. I encountered this pain when I tried to use it with JrJackson and it created the following issue: https://github.com/guyboertje/jrjackson/issues/39 .

Read comments
I am using 4.1.0 and am sending an update via:


and am getting this error here:

ArgumentError: argument must have an :id key
from /Users/u/.rvm/gems/ruby-1.9.3-p194/gems/twitter-4.1.0/lib/twitter/identity.rb:35:in `initialize'
from /Users/u/.rvm/gems/ruby-1.9.3-p194/gems/twitter-4.1.0/lib/twitter/base.rb:69:in `new'
from /Users/u/.rvm/gems/ruby-1.9.3-p194/gems/twitter-4.1.0/lib/twitter/base.rb:69:in `fetch_or_new'
from /Users/u/.rvm/gems/ruby-1.9.3-p194/gems/twitter-4.1.0/lib/twitter/base.rb:59:in `from_response'
from /Users/u/.rvm/gems/ruby-1.9.3-p194/gems/twitter-4.1.0/lib/twitter/api.rb:2351:in `object_from_response'
from /Users/u/.rvm/gems/ruby-1.9.3-p194/gems/twitter-4.1.0/lib/twitter/api.rb:1898:in `update'
from /Users/u/.rvm/gems/ruby-1.9.3-p194/gems/twitter-4.1.0/lib/twitter.rb:23:in `method_missing'
from (irb):4
from /Users/u/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands/console.rb:47:in `start'
from /Users/u/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands/console.rb:8:in `start'
from /Users/u/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands.rb:41:in `'

Whats interesting is that the tweet actually appears on the timeline of the associated app. I am not sure whats going wrong. Also interestingly enough I an similar app (slightly different bundle) I use the same twitter configuration and its all working fine. I get the same error when I invoke 'Twitter.home_timeline'

Here is my bundle config if that helps:

Using rake (
Using i18n (0.6.1)
Using multi_json (1.3.6)
Using activesupport (3.2.3)
Using builder (3.0.3)
Using activemodel (3.2.3)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.1)
Using rack-cache (1.2)
Using rack-test (0.6.2)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.1.3)
Using actionpack (3.2.3)
Using mime-types (1.19)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.4.4)
Using actionmailer (3.2.3)
Using arel (3.0.2)
Using tzinfo (0.3.33)
Using activerecord (3.2.3)
Using activeresource (3.2.3)
Using addressable (2.3.2)
Using yamler (0.1.0)
Using configatron (2.9.1)
Using apn_on_rails (0.5.1)
Using bcrypt-ruby (3.0.1)
Using nokogiri (1.5.5)
Using ffi (1.1.5)
Using childprocess (0.3.5)
Using libwebsocket (0.1.5)
Using rubyzip (0.9.9)
Using selenium-webdriver (2.25.0)
Using xpath (0.1.4)
Using capybara (1.1.2)
Using daemons (1.1.9)
Using diff-lcs (1.1.3)
Using eventmachine (1.0.0)
Using multipart-post (1.1.5)
Using faraday (0.8.4)
Using foreigner (1.2.1)
Using json (1.7.5)
Using systemu (2.5.2)
Using macaddr (1.6.1)
Using newrelic_rpm (
Using pg (0.12.2)
Using rack-protection (1.2.0)
Using rack-ssl (1.3.2)
Using bundler (1.1.5)
Using rdoc (3.12)
Using thor (0.14.6)
Using railties (3.2.3)
Using rails (3.2.3)
Using redis (3.0.2)
Using redis-namespace (1.2.1)
Using sinatra (1.3.3)
Using vegas (0.1.11)
Using resque (1.23.0)
Using rufus-scheduler (2.0.17)
Using resque-scheduler (2.0.0)
Using rspec-core (2.10.1)
Using rspec-expectations (2.10.0)
Using rspec-mocks (2.10.1)
Using rspec (2.10.0)
Using rspec-rails (2.10.0)
Using simple_oauth (0.1.9)
Using thin (1.5.0)
Using twitter (4.1.0)
Using uuid (2.3.5)
Using yajl-ruby (1.1.0)
Using yaml_db (0.2.3)

Any help is greatly appreciated!!

Read comments
@sferik this is pending some testing (see #639), but assuming all goes well, this should be good to merge. Thankfully, it was fairly easy to add support in both places.

Note: I needed to disable rubocop's ClassLength check on `Twitter::REST::Request`. I hope that's ok. I tried reducing by using ternary operators in a few places (which I typically don't like to do), but couldn't squeeze it down to <100. It seems like there could be an opportunity to reduce the number of lines once `http.rb` supports multipart requests.

Read comments
It'd be really helpful to see what changed in each version of the gem, especially notable API changes, if there was a changelog available. Unfortunately a git commit log usually only tells part of the story and in reverse.

Read comments

I have just forked the latest code but find that the tests fail.

Running "bundle exec rake spec" I get the following:
twitter/lib/twitter/status.rb:8:in `require': no such file to load -- twitter-text

Sorry, a problem with my gems.

Read comments