lib/twitter/base.rb
def request(path, options={})
        options.reverse_merge!({
          :headers => { "User-Agent" => @config[:email] },
          :method => :get
        })
        unless options[:since].blank?
          since = options[:since].kind_of?(Date) ? options[:since].strftime('%a, %d-%b-%y %T GMT') : options[:since].to_s  
          options[:headers]["If-Modified-Since"] = since
        end
        
        uri = URI.parse("http://#{@api_host}")
        
        begin
          response = Net::HTTP.start(uri.host, 80) do |http|
            klass = Net::HTTP.const_get options[:method].to_s.downcase.capitalize
            req = klass.new("#{uri.path}/#{path}", options[:headers])
            req.basic_auth(@config[:email], @config[:password]) if options[:auth]
            if options[:method].to_s == 'post' && options[:form_data]
              req.set_form_data(options[:form_data])
            end
            http.request(req)
          end
        rescue => error
          raise CantConnect, error.message
        end
        
        if %w[200 304].include?(response.code)
          response = parse(response.body)
          raise RateExceeded if (response/:hash/:error).text =~ /Rate limit exceeded/
          response
        elsif response.code == '503'
          raise Unavailable, response.message
        elsif response.code == '401'
          raise CantConnect, 'Authentication failed. Check your username and password'
        else
          raise CantConnect, "Twitter is returning a #{response.code}: #{response.message}"
        end
      end
# Makes a request to twitter.
Makes a request to twitter.
Makes a request to twitter .
def request(path, options={})
        options.reverse_merge!({
          :headers => { "User-Agent" => @config[:email] },
          :method => :get
        })
        unless options[:since].blank?
          since = options[:since].kind_of?(Date) ? options[:since].strftime('%a, %d-%b-%y %T GMT') : options[:since].to_s  
          options[:headers]["If-Modified-Since"] = since
        end
        uri = URI.parse("http://#{@api_host}")
        begin
          response = Net::HTTP.start(uri.host, 80) do |http|
            klass = Net::HTTP.const_get options[:method].to_s.downcase.capitalize
            req = klass.new("#{uri.path}/#{path}", options[:headers])
            req.basic_auth(@config[:email], @config[:password]) if options[:auth]
            if options[:method].to_s == 'post' && options[:form_data]
              req.set_form_data(options[:form_data])
            end
            http.request(req)
          end
        rescue => error
          raise CantConnect, error.message
        end
        if %w[200 304].include?(response.code)
          response = parse(response.body)
          raise RateExceeded if (response/:hash/:error).text =~ /Rate limit exceeded/
          response
        elsif response.code == '503'
          raise Unavailable, response.message
        elsif response.code == '401'
          raise CantConnect, 'Authentication failed. Check your username and password'
        else
          raise CantConnect, "Twitter is returning a #{response.code}: #{response.message}"
        end
      end
def request ( path , options = { } ) options . reverse_merge! ( { :headers => { "User-Agent" => @config [ :email ] } , :method => :get } ) unless options [ :since ] . blank? since = options [ :since ] . kind_of? ( Date ) ? options [ :since ] . strftime ( '%a, %d-%b-%y %T GMT' ) : options [ :since ] . to_s options [ :headers ] [ "If-Modified-Since" ] = since end uri = URI . parse ( "http://#{@api_host}" ) begin response = Net :: HTTP . start ( uri . host , 80 ) do | http | klass = Net :: HTTP . const_get options [ :method ] . to_s . downcase . capitalize req = klass . new ( "#{uri.path}/#{path}" , options [ :headers ] ) req . basic_auth ( @config [ :email ] , @config [ :password ] ) if options [ :auth ] if options [ :method ] . to_s == 'post' && options [ :form_data ] req . set_form_data ( options [ :form_data ] ) end http . request ( req ) end rescue => error raise CantConnect , error . message end if %w[ 200 304 ] . include? ( response . code ) response = parse ( response . body ) raise RateExceeded if ( response / :hash / :error ) . text =~ / Rate limit exceeded / response elsif response . code == '503' raise Unavailable , response . message elsif response . code == '401' raise CantConnect , 'Authentication failed. Check your username and password' else raise CantConnect , "Twitter is returning a #{response.code}: #{response.message}" end end
Makes a request to twitter.
Makes a request to twitter .
path
options