Sha256: d1fbf3903ce3e6d5a2c8a59deae658644bdaad98a0f8fa6e41eb21eef98cd67d
Contents?: true
Size: 1.04 KB
Versions: 2
Compression:
Stored size: 1.04 KB
Contents
require 'contracts' require 'twitter' # Establishes the Twitter client class TwitterClient include Contracts::Core # Shortcut for contracts C = Contracts Contract Hash => nil def initialize(credentials) # @config = { # consumer_key: '7Jw0Oc7ZVO9NHY5Z5ieYB91Rs', # consumer_secret: 'hjKJVdd2ikwHdD8SMJjDQQOxxw8FmhI22s3oGXtR7u3OllcDqf', # access_token: '794719566966333440-dR7EPJfd6wR5Wc0nhSR1yGZfKmrqPpI', # access_token_secret: 'YWwWVFhRRx84NH2VxjyxnUIiyeT2tEZZiBb8wjQ72ARRX' # } @client = Twitter::REST::Client.new(credentials) fail 'Unable to load your credentials' unless @client.credentials? end Contract String => nil # Wrapper for Twitter::Rest::Client.update with retries if too many requests def update(post) @client.update(post) rescue Twitter::Error::TooManyRequests => error # NOTE: Your process could go to sleep for up to 15 minutes but if you # retry any sooner, it will almost certainly fail with the same exception. sleep error.rate_limit.reset_in + 1 retry end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
awl_tags_twitter-0.0.4 | lib/twitter_client.rb |
awl_tags_twitter-0.0.3 | lib/twitter_client.rb |