Hi , I am writing a rake task to consume twitter stream API. The task contains the following code: consumer = OAuth::Consumer.new(CONSUMER_KEY, CONSUMER_SECRET, :site => ''http://twitter.com'') access_token OAuth::AccessToken.new(consumer,ACCESS_TOKEN,ACCESS_TOKEN_SECRET) oauth_params = {:consumer => consumer, :token => access_token} EventMachine.run do # now, let''s subscribe to twitter site stream # check informaiton on twitter site http EventMachine::HttpRequest.new(''http://stream.twitter.com/1/statuses/sample.json'').get oauth_helper = OAuth::Client::Helper.new(http, oauth_params) http.options[:head] = (http.options[:head] || {}).merge!({"Authorization" => oauth_helper.header}) http.callback { p http.response EventMachine.stop } The rake gets aborted with the following error: undefined method `options'' for #<EventMachine::HttpClient:0x42cf9f0> D:/ROR/LOCAL_TWEETS/lib/tasks/twitter.rake:40:in `block in <top (required)>'' D:/Ruby192/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0.beta.4.1-x86-mingw32/lib/ eventmachine.rb:179:in `call'' I am working on Windows 7, x64, and the gems I use are em-http-request (1.0.0) oauth (0.4.5) eventmachine (1.0.0.beta.4.1) Any ideas on how to resolve this ?? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Anait M.
2011-Sep-26 18:26 UTC
Re: undefined method `options'' for #<EventMachine::HttpClien
My eventMachine/oath/em-http-request gem combination seems to not work (pl see the code and error attached). Can anyone help me to resolve this? Thanks in advance! Attachments: http://www.ruby-forum.com/attachment/6625/undefined_method.docx -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Jeffrey L. Taylor
2011-Sep-26 18:56 UTC
Re: undefined method `options'' for #<EventMachine::HttpClien
Quoting Anait M. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>:> Hi , I am writing a rake task to consume twitter stream API. The task > contains the following code: > > consumer = OAuth::Consumer.new(CONSUMER_KEY, CONSUMER_SECRET, :site => > ''http://twitter.com'') > access_token > OAuth::AccessToken.new(consumer,ACCESS_TOKEN,ACCESS_TOKEN_SECRET) > oauth_params = {:consumer => consumer, :token => access_token} > EventMachine.run do > # now, let''s subscribe to twitter site stream > # check informaiton on twitter site > http > EventMachine::HttpRequest.new(''http://stream.twitter.com/1/statuses/sample.json'').get > oauth_helper = OAuth::Client::Helper.new(http, oauth_params) > http.options[:head] = (http.options[:head] || > {}).merge!({"Authorization" => oauth_helper.header}) > http.callback { > p http.response > > EventMachine.stop > }Not sure what you are trying to accomplish here, I''m not familiar with OAuth. A couple of points. The htpp = ....get statements makes the request, no point in altering the GET request after the fact. Perhaps you want something like: url = ''.... headers = {''Authorization'' => oauth_helper.header} http = EventMachine::HttpRequest.new(url, :head => headers).get http.callback { p http.response EventMachine.stop } HTH, Jeffrey -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.