Skip to content

Instantly share code, notes, and snippets.

@phil303
Created June 18, 2012 20:01
Show Gist options
  • Save phil303/2950400 to your computer and use it in GitHub Desktop.
Save phil303/2950400 to your computer and use it in GitHub Desktop.
gem 'oauth'
require 'rest_client'
require 'oauth'
require 'oauth/consumer'
# Instantiate consumer object
@consumer = OAuth::Consumer.new("mRoMvGuFliGOvCQTjSowLrEFjw8K5BbVp120jzsgRUG2D6y0Lq",
"ajRmJ4oWcyj9SusWAEIQLN6S400AqVgukUTEMhfvzZC7jljiA8",
site: "http://www.tumblr.com")
# Request a token. This method performs a signed http request
@request_token = @consumer.get_request_token
puts @request_token.authorize_url # outputs a url that authorizes the app
# Rails app would redirect to this url at this point
puts "Go do this"
@access_token = gets.chomp
#Exchange the request token for the access token
#@access_token = @request_token.get_access_token
response = RestClient.post "api.tumblr.com/v2/blog/user/follow", param1: "http://tomdepplito.tumblr.com/"
puts response
# Can now do whatever we need to
# access_token has all the normal http request methods
# and returns a standard ruby http response
#### Tumblr API
# All API requests start with api.tumblr.com
#
# To get blog data or write to a blog:
# api.tumblr.com/v2/blog/#{base-hostname}/...
# Example
# api.tumblr.com/v2/blog/#{base-hostname}/posts[/type]
#
# To get user data or perform user actions
# api.tumblr.com/v2/user/...
#
#
# /info — Retrieve Blog Info
# /avatar response is a string url
# /followers
# /posts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment