5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

新しい twitter gem で proxy を指定する

Last updated at Posted at 2013-04-17

検索すると古い記事にて Twitter.config から指定できるとあるが,少なくとも4.6.2では動作しない.

@t = Twitter::Client.new
@t.connection_options[:proxy] = 'http://proxy:8080'

とやれば指定できる.自分は定型句として

auth.yaml
consumer_key: hoge
consumer_secret: fuga
oauth_token: foo
oauth_token_secret: bar

と書いた auth.yaml を用意して

base.rb
require 'twitter'
class Base
  def initialize
    config = YAML.load_file("./auth.yaml")
    @t = Twitter::Client.new
    config.each_pair do |k, v|
      @t.send("#{k}=", v)
    end
    @t.connection_options[:proxy] = 'proxy:8080'
  end
end

という感じで初期化している.

5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?