Module: Tweetlr::Processors::Tumblr
- Includes:
- LogAware
- Defined in:
- lib/tweetlr/processors/tumblr.rb
Overview
utilities for handling tumblr
Constant Summary collapse
- GENERATOR =
%{tweetlr - http://tweetlr.5v3n.com}
- API_ENDPOINT_TUMBLR =
'http://www.tumblr.com'
Class Method Summary collapse
- .log ⇒ Object
-
.post(options = {}) ⇒ Object
post a tumblr photo entry.
Methods included from LogAware
Class Method Details
.log ⇒ Object
10 11 12 |
# File 'lib/tweetlr/processors/tumblr.rb', line 10 def self.log Tweetlr::LogAware.log #TODO why doesn't the include make the log method accessible? end |
.post(options = {}) ⇒ Object
post a tumblr photo entry.
required arguments are :tumblr_blog_hostname, :tumblr_blog_hostname, :tumblr_oauth_api_secret, :tumblr_oauth_access_token_secret, :source, :caption, :state
optional arguments: :tags, :type (default: ‘photo’)
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/tweetlr/processors/tumblr.rb', line 19 def self.post(={}) base_hostname = [:tumblr_blog_hostname] || [:group] tumblr_oauth_api_key= [:tumblr_oauth_api_key] tumblr_oauth_api_secret= [:tumblr_oauth_api_secret] access_token_key = [:tumblr_oauth_access_token_key] access_token_secret = [:tumblr_oauth_access_token_secret] type = [:type] || 'photo' = [:tags] || '' post_response = nil if base_hostname && access_token_key && access_token_secret consumer = OAuth::Consumer.new(tumblr_oauth_api_key, tumblr_oauth_api_secret, { :site => 'http://www.tumblr.com', :request_token_path => '/oauth/request_token', :authorize_path => '/oauth/authorize', :access_token_path => '/oauth/access_token', :http_method => :post } ) access_token = OAuth::AccessToken.new(consumer, access_token_key, access_token_secret) post_response = access_token.post( "http://api.tumblr.com/v2/blog/#{base_hostname}/post", { :type => type, :source => [:source], :caption => [:caption], :date => [:date], :tags => , :state => [:state], :generator => GENERATOR } ) end post_response end |