tumblr-follow 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/bin/run_this_for_tumblr_oauth_tokens +48 -0
- data/lib/tumblr-follow.rb +36 -0
- data/lib/tumblr-follow/version.rb +3 -0
- data/tumblr-follow.gemspec +20 -0
- metadata +88 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Phil Aquilina
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Tumblr-follow
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
gem install tumblr-follow
|
6
|
+
|
7
|
+
|
8
|
+
## Usage
|
9
|
+
|
10
|
+
1. Run executable file `run_this_for_tumblr_oauth_tokens` to get your OAuth
|
11
|
+
token and secret
|
12
|
+
2. To set api key and api secret:
|
13
|
+
|
14
|
+
Tumblr::api_key = your_key
|
15
|
+
Tumblr::api_secret = your_secret
|
16
|
+
|
17
|
+
3. To follow someone:
|
18
|
+
|
19
|
+
your_account = Tumblr::Account.new(:oauth_token => your_oauth_token,
|
20
|
+
:oauth_secret => your_oauth_secret)
|
21
|
+
|
22
|
+
your_account.follow!(tumblr_account)
|
23
|
+
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'oauth'
|
4
|
+
require 'oauth/consumer'
|
5
|
+
require 'launchy'
|
6
|
+
|
7
|
+
# Instantiate consumer object
|
8
|
+
puts "Paste in your consumer key:"
|
9
|
+
consumer_key = gets.chomp
|
10
|
+
puts "Paste in your secret key:"
|
11
|
+
secret_key = gets.chomp
|
12
|
+
|
13
|
+
# this is where my_app registers with Tumblr and receives its first set of keys
|
14
|
+
@consumer = OAuth::Consumer.new(consumer_key,
|
15
|
+
secret_key,
|
16
|
+
site: "http://www.tumblr.com")
|
17
|
+
|
18
|
+
# my_app takes the first set of keys and uses them to to sign a special
|
19
|
+
# request for a new set of keys, the request token
|
20
|
+
@request_token = @consumer.get_request_token
|
21
|
+
|
22
|
+
# with the request token in hand, we go back to Tumblr and the user is asked
|
23
|
+
# whether to allow or deny my_apps request to access data
|
24
|
+
Launchy.open @request_token.authorize_url
|
25
|
+
|
26
|
+
puts "\nPaste url from post authorization:"
|
27
|
+
url = gets
|
28
|
+
|
29
|
+
# Tumblr then sends user back to my_app saying the request is verified
|
30
|
+
# my_app takes the request token and uses it to sign a new request to Tumblr
|
31
|
+
# for the final keys, the access token
|
32
|
+
oauth_verifier = url.match(/oauth_verifier=(.+)\n/)[1]
|
33
|
+
|
34
|
+
# If we don't yet have an access token, we need to go through the
|
35
|
+
# OAuth redirect and copy the oauth_verifier from the URL
|
36
|
+
# We can then use the method below to trade our oauth_verifier for
|
37
|
+
# and access token. Be careful, oauth_verifiers expire on the order of
|
38
|
+
# minutes
|
39
|
+
|
40
|
+
@access_token = @request_token.get_access_token(:oauth_verifier => oauth_verifier)
|
41
|
+
|
42
|
+
puts <<-EOF
|
43
|
+
|
44
|
+
OAUTH_TOKEN = '#{@access_token.token}'
|
45
|
+
OAUTH_SECRET = '#{@access_token.secret}'
|
46
|
+
|
47
|
+
EOF
|
48
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'oauth'
|
2
|
+
require 'oauth/consumer'
|
3
|
+
require 'launchy'
|
4
|
+
|
5
|
+
module Tumblr
|
6
|
+
class << self
|
7
|
+
attr_accessor :api_key, :api_secret
|
8
|
+
end
|
9
|
+
|
10
|
+
class Account
|
11
|
+
def initialize(opts = {})
|
12
|
+
@api_key = Tumblr::api_key
|
13
|
+
@api_secret = Tumblr::api_secret
|
14
|
+
@oauth_token = opts.fetch(:oauth_token)
|
15
|
+
@oauth_secret = opts.fetch(:oauth_secret)
|
16
|
+
|
17
|
+
@consumer = OAuth::Consumer.new(@api_key,
|
18
|
+
@api_secret,
|
19
|
+
site: "http://www.tumblr.com")
|
20
|
+
@access_token = OAuth::AccessToken.new(@consumer, @oauth_token, @oauth_secret)
|
21
|
+
end
|
22
|
+
|
23
|
+
def follow!(username)
|
24
|
+
post('/v2/user/follow', url: "#{username}.tumblr.com")
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def post(*args)
|
29
|
+
@access_token.post(*args)
|
30
|
+
end
|
31
|
+
|
32
|
+
def get(*args)
|
33
|
+
@access_token.get(*args)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/tumblr-follow/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Phil Aquilina"]
|
6
|
+
gem.email = ["philaquilina@gmail.com"]
|
7
|
+
gem.description = %q{Small gem to interface with Tumblr follow api}
|
8
|
+
gem.summary = %q{Small gem to interface with Tumblr follow api}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "tumblr-follow"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Tumblr::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency('oauth')
|
19
|
+
gem.add_dependency('launchy')
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tumblr-follow
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Phil Aquilina
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: oauth
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: launchy
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Small gem to interface with Tumblr follow api
|
47
|
+
email:
|
48
|
+
- philaquilina@gmail.com
|
49
|
+
executables:
|
50
|
+
- run_this_for_tumblr_oauth_tokens
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- Gemfile
|
56
|
+
- LICENSE
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- bin/run_this_for_tumblr_oauth_tokens
|
60
|
+
- lib/tumblr-follow.rb
|
61
|
+
- lib/tumblr-follow/version.rb
|
62
|
+
- tumblr-follow.gemspec
|
63
|
+
homepage: ''
|
64
|
+
licenses: []
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 1.8.23
|
84
|
+
signing_key:
|
85
|
+
specification_version: 3
|
86
|
+
summary: Small gem to interface with Tumblr follow api
|
87
|
+
test_files: []
|
88
|
+
has_rdoc:
|