Giter Club home page Giter Club logo

twitter-ruby's People

Contributors

adambird avatar cyu avatar dcrec1 avatar erebor avatar fabienchaynes avatar gsomoza avatar haileys avatar jaredbeck avatar jnak avatar jnunemaker avatar korny avatar kunalmodi avatar laserlemon avatar michaelherold avatar natebarnes avatar nbraem avatar neektza avatar nidev avatar paulwalker avatar pengwynn avatar rrrene avatar secobarbital avatar sferik avatar spurton avatar stve avatar tibbon avatar tomykaira avatar wjlroe avatar ys avatar zmoazeni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

twitter-ruby's Issues

Mash modifies Hash class, breaks my app.

title says it all. Mash redefines stringify_keys and stringify_keys! to have deep-stringify type functionality, but it should not be modifying Hash.

Can we avoid using (or patch) mash?

Add API cacheing

Is there some kind of build in caching? api_cache seems to be quite interesting and easy to use. but it does not work to marshall the array of mashes. as a workarount i can go through to_json, but that seems really odd

tag.locals.tweets = JSON.parse(APICache.get("list_timeline_#{tag.locals.user}_#{tag.attr['list']}_#{tag.locals.max}".dup, :cache => 3600) do
  begin
    Twitter.list_timeline(tag.locals.user,tag.attr['list'], {:page => 1, :per_page => tag.locals.max} ).to_json
  rescue Exception => e
    logger.error "Unable to fetch user list: #{e.inspect}"
    raise APICache::InvalidResponse
  end
  end).map{|hash| Hashie::Mash.new(hash)}

this "works" but it does not look right

http://github.com/mloughran/api_cache is what I was looking for to use

or is this whole idea not appealing?

Add xAuth support

For building desktop applications, it'd be really handy to support XAuth. (A nice summary is here: http://www.reynoldsftw.com/2010/03/using-xauth-an-alternate-oauth-from-twitter/)

I might be able to provide a patch to add this support, but need to know how best to generate the OAuth authorisation scheme (nonce, timestamp, etc), which is used by the Twitter API method described here: http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-oauth-access_token-for-xAuth

Does anybody know how best to generate the authorisation scheme? (How) can the Ruby OAuth gem be used for this purpose?

HTTPS

could we have someone enabling https support on the oauth and api call?

Problem with list_remove_user

list_add_member works just fine but when trying list_remove_user i get
this error

Twitter::RateLimitExceeded: (400): Bad Request - You must specify a
member

Which is the same error you get if you use the api via curl and leave
off the id
http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-DELETE-list-members

It has nothing to do with the rate limit. twitter gem just returns all
400's as a ratelimitexceded. There is no rate limit for adding and
removing list items and also my account is white listed.

A user-agent is required for twitter searches

I think this may be a new change to twitter, but user-agents are now required or else it will return a 400 Bad Request.

Add this line to work around it for now:
Twitter::Search.default_options = {:headers => {'User-Agent' =>
'YOUR_USER_AGENT_STRING'}}

JSON parsing error with Crack

Crack seems to have problem's with Twitter's JSON format. If I use the Rails json gem instead, I have no problems.

/Library/Ruby/Gems/1.8/gems/crack-0.1.1/lib/crack/json.rb:14:in `parse': Invalid JSON string (Crack::ParseError)

Use OAuth 0.3.4

Twitter gem uses OAuth 0.3.2 instead of the current version.

no exception thrown with client.update(text) when text is > 140 characters

Hey,

I was looking into this in the twitter gem and it appears there is no way to know if a message post was successful or not. Is this the case with the twitter API?

I know I know, should limit the text to 140 first. I think the lib should still throw an exception in this case... (not if the text is too long) but if the message post failed.

What you think?

Best,
Dave

Add special handling for Twitter commands

when u try to post a msg "DM of company fired his employees" DM as deputy manager it should fail.

Is there any provision to escape it? Ideally it should be functionality in the client.

Version constraints for Mash (v0.0.3) and other dependencies

Twitter gem should use pessimistic version constraints for dependencies. My proposal:

oauth ~> 0.3.5
mash ~> 0.0.3
httparty ~> 0.4.3

Right now the dependencies are:

oauth (>= 0.3.5, runtime)
mash (= 0.0.3, runtime)
httparty (= 0.4.3, runtime)

This means when newer "mash" is released (github version is v0.0.7 now) with much needed bugfixes, twitter gem will currently not load it because it's locked to v0.0.3. With a pessimistic version constraint, it will load any newer 0.0.x version.

Also, currently if an incompatible new OAuth gem is released—let's imagine v0.5.0—twitter gem will load it without second thought and that might break functionality. With a pessimistic version constraint, it will only load newer 0.3.x releases, but never 0.4.0 or higher.

Twitter::Unauthorized: (401)

I'm getting an 401 Unauthorized Incorrect Signature. I'm using twitter 0.7.9 and oauth 0.3.6.
Sometimes this error occured and sometimes i got no error, i've tried to find out what's the problem but i got no clue. Looks like the error occured on verify credentials, here is the stack trace of the error:

Twitter::Unauthorized: (401): Unauthorized - Incorrect signature
from /usr/local/lib/ruby/gems/1.8/gems/twitter-0.7.9/lib/twitter/request.rb:75:in raise_errors' from /usr/local/lib/ruby/gems/1.8/gems/twitter-0.7.9/lib/twitter/request.rb:63:inmake_friendly'
from /usr/local/lib/ruby/gems/1.8/gems/twitter-0.7.9/lib/twitter/request.rb:42:in perform' from /usr/local/lib/ruby/gems/1.8/gems/twitter-0.7.9/lib/twitter/request.rb:6:inget'
from /usr/local/lib/ruby/gems/1.8/gems/twitter-0.7.9/lib/twitter/base.rb:315:in perform_get' from /usr/local/lib/ruby/gems/1.8/gems/twitter-0.7.9/lib/twitter/base.rb:145:inverify_credentials'
from /home/dimas/Works/my_app/app/models/twitter_account.rb:42:in `backup'
from (irb):5

Thanks,
Dimas Priyanto

0.9.5 seems to have yajl-ruby dependency problem

Hi, when installing twitter gem version 0.9.5, I keep getting the following error when requiring the gem -- looks like it is calling the yajl dependency incorrectly maybe:

require 'twitter'
LoadError: Failed to load /usr/local/lib/ruby/gems/1.8/gems/yajl-ruby-0.7.5/lib/yajl_ext.bundle
from /usr/local/lib/ruby/gems/1.8/gems/yajl-ruby-0.7.5/lib/yajl_ext.bundle
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in require' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:inrequire'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in new_constants_in' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:inrequire'
from /usr/local/lib/ruby/gems/1.8/gems/yajl-ruby-0.7.5/lib/yajl.rb:2
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in require' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:innew_constants_in'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in require' from /usr/local/lib/ruby/gems/1.8/gems/twitter-0.9.5/lib/twitter.rb:5 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:ingem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in require' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:inrequire'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in new_constants_in' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:inrequire'
from (irb):2>> exit

Installing Twitter gem version 0.9.4 instead of 0.9.5 fixes the problem for me. Thought you should be aware

list_subscribers needs a query option too

list_subscribers uses a cursor. Currently there's no way to pass this in.

It's probably a simple mod in base.rb to pass through the query param as is done with list_members.

Potential ambiguity in friendship_create method

Twitter has updated the friendship_create method so that it can consume an explicit user_id or screen_name parameter vs the potentially ambiguous "id", which could be either of those values.

Would be best to reflect this specificity in the Twitter gem. (Sorry, I'm a n00b. Wouldn't knwow where to begin.)

Note, I haven't taken a pass over the Twitter API to see if this change was made to other methods that consume "id" as a param.

Thanks.

Status url (and solution)

I just started using this gem and noticed that when you inspect a single status (class Hashie::Mash) the method .url always returns nil. This was an issue for me, so I've found a solution with a function that seems to return the url address of a single status:

"http://twitter.com/#{from_user}/status/#{id}"

I hope this is of help.

uninitialized constant Twitter::OAuth

In an attempt to use the Twitter gem in my Rails app, I'm being presented with the following exception: uninitialized constant Twitter::OAuth

It occurs when trying to instantiate OAuth.
oauth = Twitter::OAuth.new(ServiceAPIKeys.twitter['api_key'], ServiceAPIKeys.twitter['secret_key'])

I have all of the dependencies installed and the gems are unpacked in my vendor/gem directory.

Thoughts?

Methods on Twitter class don't check for errors

The methods on the Twitter class (firehose, friend_ids, follower_ids, status, user) assume that no errors will occur, but all of them can at least return a 50x error. An example using FakeWeb:

>> FakeWeb.register_uri(:get, 'http://twitter.com/statuses/public_timeline.json',
?> :string => '{"request":"\/statuses\/public_timeline.json","error":"Bad gateway"}',
?> :status => ['502', 'Bad Gateway'])
=> [#["502", "Bad Gateway"], :string=>"{\"request\":\"\\/statuses\\/public_timeline.json\",\"error\":\"Bad gateway\"}"}, @method=:get, @uri="http://twitter.com/statuses/public_timeline.json", @times=1>]
>> Twitter.firehose
NoMethodError: undefined method `stringify_keys' for ["request", "/statuses/public_timeline.json"]:Array
        from /usr/lib/ruby/gems/1.8/gems/mash-0.0.3/lib/mash.rb:131:in `deep_update'
        from /usr/lib/ruby/gems/1.8/gems/mash-0.0.3/lib/mash.rb:50:in `initialize'
        from /usr/lib/ruby/gems/1.8/gems/twitter-0.6.11/lib/twitter.rb:34:in `new'
        from /usr/lib/ruby/gems/1.8/gems/twitter-0.6.11/lib/twitter.rb:34:in `firehose' 

Using the gem in async mode

As the number of calls we make to twitter increases, we would like it to be async. Any chance of adding support for async (thru em-http perhaps)?

Thx!

Crack error when creating friendship

Not sure if this is an issue with Crack or with this lib, but every time I try to create a friendship, I get this error:

base.friendship_create('anyone')
Crack::ParseError: Invalid JSON string
from /Library/Ruby/Gems/1.8/gems/crack-0.1.2/lib/crack/json.rb:14:in parse' from /Library/Ruby/Gems/1.8/gems/twitter-0.6.8/lib/twitter/request.rb:73:inparse'
from /Library/Ruby/Gems/1.8/gems/twitter-0.6.8/lib/twitter/request.rb:48:in make_friendly' from /Library/Ruby/Gems/1.8/gems/twitter-0.6.8/lib/twitter/request.rb:34:inperform'
from /Library/Ruby/Gems/1.8/gems/twitter-0.6.8/lib/twitter/request.rb:10:in post' from /Library/Ruby/Gems/1.8/gems/twitter-0.6.8/lib/twitter/base.rb:162:inperform_post'
from /Library/Ruby/Gems/1.8/gems/twitter-0.6.8/lib/twitter/base.rb:76:in `friendship_create'

Handling http errors

We are having the handle errors such as the ones below:

rescue Errno::ETIMEDOUT,
Errno::ECONNREFUSED,
Timeout::Error,
StandardError => e

Shouldnt they be caught at the API level and appropriate exception be bubbled up to us?

since_date doesn't return any results

I am not sure if I am calling the method correctly but I am not able to get any results back when I specify the since_date:

Example:
Twitter::Search.new.from('user').since_date('2010-07-07').fetch().results, returns nil

Mash/extlib don't like each other

Currently there’s no way to use twitter gem along with ExtLib gem (which is e.g. used by DataMapper).

Both ExtLib and mash gem (used by twitter) declare separate notions of a Mash class with different semantics. This results in infinite recursion (“stack level too deep” error).

This bug is also posted here: https://mbleigh.lighthouseapp.com/projects/10112-mash/tickets/3-mash-conflicting-with-extlib

Check to see if oauth is authorized

It is sometimes useful to see if the client is authorized or not, and here is the method I added to the Twitter::Base class to check using an example taken from twitter_oauth:

def authorized?
oauth_response = client.access_token.get('/account/verify_credentials.json')
oauth_response.class == Net::HTTPOK
end

I am sure there is a better way of doing this, but this is the way that I am doing it and it isn't taking an extra API Hits.

Thanks,

Dan

Twitter::Base#users fails on 1.9.1

On Ruby 1.9.1 (not tested 1.8.7):

The array I'm passing as arguments: ["itv1", "cloggingchris", "ToryatSea", "Conservatives", "TheOrwellPrize", "timespolitics"]
The array the splat returns within the function: [["itv1", "cloggingchris", "ToryatSea", "Conservatives", "TheOrwellPrize", "timespolitics"]]
/usr/local/lib/ruby/gems/1.9.1/gems/twitter-0.9.4/lib/twitter.rb:89:in `raise_errors': (404): Not Found (Twitter::NotFound)
        from /usr/local/lib/ruby/gems/1.9.1/gems/twitter-0.9.4/lib/twitter.rb:67:in `make_friendly'
        from /usr/local/lib/ruby/gems/1.9.1/gems/twitter-0.9.4/lib/twitter/request.rb:42:in `perform'
        from /usr/local/lib/ruby/gems/1.9.1/gems/twitter-0.9.4/lib/twitter/request.rb:6:in `get'
        from /usr/local/lib/ruby/gems/1.9.1/gems/twitter-0.9.4/lib/twitter/base.rb:356:in `perform_get'
        from /usr/local/lib/ruby/gems/1.9.1/gems/twitter-0.9.4/lib/twitter/base.rb:111:in `users'
        from /home/james/backchat/lib/backchat/parser.rb:103:in `lookup_mentioned_users'
        from bin/parser_test:11:in `'

As a hotfix, simply selecting [0] of the splat return works, but this probably breaks 1.8.7 if this works there, so a more robust fix is required.

nil.downcase - NoMethodError: You have a nil object when you didn't expect it!

Hi

Im not sure if this is a problem with the twitter gem or oauth gem, although twitter gem 0.9.5 has worked fine with the oauth gem 0.3.6 i have been using previously.
When making any api calls i get the following error:

client.rate_limit_status
NoMethodError: You have a nil object when you didn't expect it!
The error occurred while evaluating nil.downcase
from /Users/eddy/.gem/ruby/1.8/gems/oauth-0.3.6/lib/oauth/request_proxy/base.rb:92:in normalized_uri' from /Users/eddy/.gem/ruby/1.8/gems/oauth-0.3.6/lib/oauth/request_proxy/base.rb:112:insignature_base_string'
from /Users/eddy/.gem/ruby/1.8/gems/oauth-0.3.6/lib/oauth/signature/base.rb:66:in signature_base_string' from /Users/eddy/.gem/ruby/1.8/gems/oauth-0.3.6/lib/oauth/signature/hmac/base.rb:9:indigest'
from /Users/eddy/.gem/ruby/1.8/gems/oauth-0.3.6/lib/oauth/signature/base.rb:54:in signature' from /Users/eddy/.gem/ruby/1.8/gems/oauth-0.3.6/lib/oauth/signature.rb:20:insign'
from /Users/eddy/.gem/ruby/1.8/gems/oauth-0.3.6/lib/oauth/client/helper.rb:44:in signature' from /Users/eddy/.gem/ruby/1.8/gems/oauth-0.3.6/lib/oauth/client/helper.rb:67:inheader'
from /Users/eddy/.gem/ruby/1.8/gems/oauth-0.3.6/lib/oauth/client/net_http.rb:80:in set_oauth_header' from /Users/eddy/.gem/ruby/1.8/gems/oauth-0.3.6/lib/oauth/client/net_http.rb:35:insend'
from /Users/eddy/.gem/ruby/1.8/gems/oauth-0.3.6/lib/oauth/client/net_http.rb:35:in oauth!' from /Users/eddy/.gem/ruby/1.8/gems/oauth-0.3.6/lib/oauth/consumer.rb:208:insign!'
from /Users/eddy/.gem/ruby/1.8/gems/oauth-0.3.6/lib/oauth/consumer.rb:177:in create_signed_request' from /Users/eddy/.gem/ruby/1.8/gems/oauth-0.3.6/lib/oauth/consumer.rb:149:inrequest'
from /Users/eddy/.gem/ruby/1.8/gems/oauth-0.3.6/lib/oauth/tokens/consumer_token.rb:25:in request' from /Users/eddy/.gem/ruby/1.8/gems/oauth-0.3.6/lib/oauth/tokens/access_token.rb:11:inrequest'
from /Users/eddy/.gem/ruby/1.8/gems/oauth-0.3.6/lib/oauth/tokens/access_token.rb:24:in get' from /Users/eddy/.gem/ruby/1.8/gems/twitter-0.9.7/lib/twitter/request.rb:48:inperform_get'
from /Users/eddy/.gem/ruby/1.8/gems/twitter-0.9.7/lib/twitter/request.rb:42:in send' from /Users/eddy/.gem/ruby/1.8/gems/twitter-0.9.7/lib/twitter/request.rb:42:inperform'
from /Users/eddy/.gem/ruby/1.8/gems/twitter-0.9.7/lib/twitter/request.rb:6:in get' from /Users/eddy/.gem/ruby/1.8/gems/twitter-0.9.7/lib/twitter/base.rb:374:inperform_get'
from /Users/eddy/.gem/ruby/1.8/gems/twitter-0.9.7/lib/twitter/base.rb:192:in `rate_limit_status'

Any ideas?
Thanks

Add support for Twitter-clone end points

It appears that the focus is totally on twitter and support for other end points is being yanked out.

As of 0.9.5 base API version is being hard coded to 1 and they are is no way to change.
Removal of basic authentication 0.9.7 (http://twitter.com/pengwynn/status/14735702512)

Pls note that there are folks like us that use it with other end points. Can we assume that you will continue to support other end points? We really hope you do, happy to provide a patch for the API versioning later this evening.

Thx! Pls revert!

Invalid / expired Token when confirming oauth

Slightly confused here.

Two code snippets:

  1. Get the auth URL:
  oauth = Twitter::OAuth.new(consumer_key, consumer_secret)

  @auth_url = oauth.request_token.authorize_url

Following the URL gives me the "Deny/Allow screen with the correct consumer name - so twitter has found the correct consumer info.

  1. Get the access token:
    oauth = Twitter::OAuth.new(consumer_key, consumer_secret)
 oauth.authorize_from_request(consumer_key, consumer_secret, pin)

 access_token = oauth.access_token

On the authorize_from_request I get a 401. Debugging the call shows that the response from twitter is:

<?xml version="1.0" encoding="UTF-8"?>
<hash>
    <request>/oauth/access_token</request>
    <error>Invalid / expired Token</error>
</hash>

I have this consumer pair working fine using twitter4j in java - so the consumer seems OK on the twitter side.

Any ideas why this is failing? Have I missed something obvious in the code here?

Yajl-Ruby dependency causing seg fault with cucumber selenium json requests

I guess this is really a yajl-ruby issue but I thought other 0.9.5 twitter users might verify this.

We get seg faults on cucumber features with json requests when we use twitter 0.9.5 and it seems to be an issue with yajl-ruby:

.../Users/jonathangreenberg/.rvm/gems/ruby-1.8.7-p174/gems/activesupport-2.3.5/lib/active_support/json/encoding.rb:70: [BUG] Bus Error
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin9.8.0]

Note that this was very tricky to track down because even reverting to older twitter gems (e.g. 0.8.3) would still have the seg fault until the yajl-ruby gem was removed even though there does not appear to be a dependency on yajl-ruby.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.