twitter_atm 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/README.txt +20 -0
- data/Rakefile +2 -0
- data/bin/twitter_atm +44 -0
- data/lib/twitter_atm.rb +6 -0
- data/lib/twitter_atm/client.rb +21 -0
- data/lib/twitter_atm/version.rb +8 -0
- data/twitter_atm.gemspec +24 -0
- metadata +101 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm 1.9.2@twitter_atm
|
data/Gemfile
ADDED
data/README.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
This isn't a thing that makes Twitter give you cash. This is a thing where you
|
2
|
+
use a PIN to get something. Specifically, this is a simple tool for navigating
|
3
|
+
Twitter's PIN-based OAuth path from the command line. My use case is when I have
|
4
|
+
an application that will tweet programatically, but only to one account ever. I
|
5
|
+
don't want to build a callback web page or all that and I don't want to keep
|
6
|
+
looking up how to do this process, so I made a simple gem.
|
7
|
+
|
8
|
+
Usage is like this:
|
9
|
+
|
10
|
+
$ twitter_atm --secret=2389rh2fgi8hg10938uftr12 --username=benhamill
|
11
|
+
Go to http://twitter.com/whatever/get/a/real/example?some_arg=stuff&other=things
|
12
|
+
|
13
|
+
Then you log in and hit yes and get the pin and do this:
|
14
|
+
|
15
|
+
$ twitter_atm --pin=1234567 --secret=309r8uy08gtg2orwhatever
|
16
|
+
Your OAuth credentials are... some format. Haven't worked this out exactly.
|
17
|
+
|
18
|
+
Simple.
|
19
|
+
|
20
|
+
Props to @hoonpark for the name idea.
|
data/Rakefile
ADDED
data/bin/twitter_atm
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require 'twitter_atm'
|
5
|
+
|
6
|
+
class TwitterAtm::Commands < Thor
|
7
|
+
include Thor::Actions
|
8
|
+
|
9
|
+
desc "get_creds", "To start, put the username and your app secret in here."
|
10
|
+
method_options :consumer_key => :required, :consumer_secret => :required
|
11
|
+
def get_creds
|
12
|
+
client = TwitterAtm::Client.new(options[:consumer_key], options[:consumer_secret])
|
13
|
+
|
14
|
+
say "Requesting PIN..."
|
15
|
+
|
16
|
+
begin
|
17
|
+
url = client.authorize_url
|
18
|
+
rescue OAuth::Unauthorized => e
|
19
|
+
say "Looks like you're not authorized. Did you put in the right keys?"
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
|
23
|
+
say "Go to #{url}"
|
24
|
+
pin = ask "Enter the pin here:"
|
25
|
+
say "Authorizing..."
|
26
|
+
|
27
|
+
begin
|
28
|
+
token, secret = client.authorize pin
|
29
|
+
rescue OAuth::Unauthorized => e
|
30
|
+
say "Wrong PIN. Try again?"
|
31
|
+
exit
|
32
|
+
end
|
33
|
+
|
34
|
+
say "Store these somewhere in order to tweet as this user."
|
35
|
+
say " token: #{token}"
|
36
|
+
say " secret: #{secret}"
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "version", "Displays the current version of twitter_atm."
|
40
|
+
def version
|
41
|
+
puts TwitterAtm.version
|
42
|
+
end
|
43
|
+
end
|
44
|
+
TwitterAtm::Commands.start
|
data/lib/twitter_atm.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'twitter_oauth'
|
2
|
+
|
3
|
+
class TwitterAtm::Client
|
4
|
+
attr_accessor :client, :request_token
|
5
|
+
|
6
|
+
def initialize consumer_key, consumer_secret
|
7
|
+
@client = TwitterOAuth::Client.new(:consumer_key => consumer_key, :consumer_secret => consumer_secret)
|
8
|
+
end
|
9
|
+
|
10
|
+
def authorize_url
|
11
|
+
@request_token = client.request_token
|
12
|
+
request_token.authorize_url
|
13
|
+
end
|
14
|
+
|
15
|
+
def authorize pin
|
16
|
+
client.authorize request_token.token, request_token.secret, :pin => pin.to_i
|
17
|
+
access_token = client.send :access_token
|
18
|
+
|
19
|
+
[access_token.token, access_token.secret]
|
20
|
+
end
|
21
|
+
end
|
data/twitter_atm.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "twitter_atm/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "twitter_atm"
|
7
|
+
s.version = TwitterAtm::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Ben Hamill"]
|
10
|
+
s.email = ["ben at benhamill dot com"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{Use the command line to navigate Twitter's PIN-based OAuth flow.}
|
13
|
+
s.description = %q{A simple command line tool for navigating Twitter's Pin-based OAuth path and outputting the credentials received to stdout.}
|
14
|
+
|
15
|
+
s.rubyforge_project = "twitter_atm"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_dependency("twitter_oauth", "~> 0.4")
|
23
|
+
s.add_dependency("thor", "~> 0.14")
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: twitter_atm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 1.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Ben Hamill
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-01-13 00:00:00 -06:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: twitter_oauth
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
- 4
|
31
|
+
version: "0.4"
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: thor
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ~>
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
segments:
|
43
|
+
- 0
|
44
|
+
- 14
|
45
|
+
version: "0.14"
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
48
|
+
description: A simple command line tool for navigating Twitter's Pin-based OAuth path and outputting the credentials received to stdout.
|
49
|
+
email:
|
50
|
+
- ben at benhamill dot com
|
51
|
+
executables:
|
52
|
+
- twitter_atm
|
53
|
+
extensions: []
|
54
|
+
|
55
|
+
extra_rdoc_files: []
|
56
|
+
|
57
|
+
files:
|
58
|
+
- .gitignore
|
59
|
+
- .rvmrc
|
60
|
+
- Gemfile
|
61
|
+
- README.txt
|
62
|
+
- Rakefile
|
63
|
+
- bin/twitter_atm
|
64
|
+
- lib/twitter_atm.rb
|
65
|
+
- lib/twitter_atm/client.rb
|
66
|
+
- lib/twitter_atm/version.rb
|
67
|
+
- twitter_atm.gemspec
|
68
|
+
has_rdoc: true
|
69
|
+
homepage: ""
|
70
|
+
licenses: []
|
71
|
+
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
segments:
|
83
|
+
- 0
|
84
|
+
version: "0"
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
segments:
|
91
|
+
- 0
|
92
|
+
version: "0"
|
93
|
+
requirements: []
|
94
|
+
|
95
|
+
rubyforge_project: twitter_atm
|
96
|
+
rubygems_version: 1.3.7
|
97
|
+
signing_key:
|
98
|
+
specification_version: 3
|
99
|
+
summary: Use the command line to navigate Twitter's PIN-based OAuth flow.
|
100
|
+
test_files: []
|
101
|
+
|