Created
December 31, 2010 12:05
-
-
Save berkes/760960 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Services::Twitter < Service | |
MAX_CHARACTERS = 140 | |
def post(post, url='') | |
Rails.logger.debug("event=post_to_service type=twitter sender_id=#{self.user_id}") | |
message = public_message(post, url) | |
twitter_key = SERVICES['twitter']['consumer_key'] | |
twitter_consumer_secret = SERVICES['twitter']['consumer_secret'] | |
if twitter_consumer_secret.blank? || twitter_consumer_secret.blank? | |
Rails.logger.info "you have a blank twitter key or secret.... you should look into that" | |
end | |
Twitter.configure do |config| | |
config.consumer_key = twitter_key | |
config.consumer_secret = twitter_consumer_secret | |
config.oauth_token = self.access_token | |
config.oauth_token_secret = self.access_secret | |
end | |
begin | |
Twitter.update(message) | |
rescue Exception => e | |
Rails.logger.info e.message | |
end | |
end | |
def public_message(post, url) | |
super(post, MAX_CHARACTERS, url) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment