facebook_test_accounts 0.0.1
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 +5 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +19 -0
- data/README.markdown +12 -0
- data/Rakefile +2 -0
- data/bin/facebook_test_accounts +5 -0
- data/facebook_test_accounts.gemspec +24 -0
- data/lib/facebook_test_accounts/account_creator.rb +72 -0
- data/lib/facebook_test_accounts/bin.rb +25 -0
- data/lib/facebook_test_accounts/version.rb +3 -0
- data/lib/facebook_test_accounts.rb +11 -0
- metadata +107 -0
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (C) 2011 by Peter Brindisi, frestyl
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
### Facebook Test Accounts ###
|
2
|
+
|
3
|
+
A simple command-line utility to easily create test accounts for your facebook apps.
|
4
|
+
|
5
|
+
> facebook_test_accounts --app-id APP_ID \
|
6
|
+
--secret APP_SECRET \
|
7
|
+
--installed true \
|
8
|
+
--permissions "read_stream,publish_stream,offline_access"
|
9
|
+
|
10
|
+
That's just about it. Enjoy.
|
11
|
+
|
12
|
+
Copyright (c) 2011 by Peter Brindisi, frestyl
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "facebook_test_accounts/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "facebook_test_accounts"
|
7
|
+
s.version = FacebookTestAccounts::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Peter Brindisi", "frestyl"]
|
10
|
+
s.email = ["npj@frestyl.com", "info@frestyl.com"]
|
11
|
+
s.homepage = "https://github.com/frestyl/facebook_test_accounts"
|
12
|
+
s.summary = %q{Easily create test accounts for your facebook app}
|
13
|
+
s.description = %q{Easily create test accounts for your facebook app}
|
14
|
+
|
15
|
+
s.rubyforge_project = "facebook_test_accounts"
|
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("trollop")
|
23
|
+
s.add_dependency("httparty")
|
24
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module FacebookTestAccounts
|
2
|
+
class AccountCreator
|
3
|
+
|
4
|
+
include HTTParty
|
5
|
+
base_uri "https://graph.facebook.com"
|
6
|
+
|
7
|
+
def initialize(options = { })
|
8
|
+
@app_id = options[:app_id]
|
9
|
+
@secret = options[:secret]
|
10
|
+
@installed = options[:installed]
|
11
|
+
@permissions = options[:permissions]
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_account
|
15
|
+
print_account_info(create_test_account(fetch_access_token))
|
16
|
+
end
|
17
|
+
|
18
|
+
def fetch_access_token
|
19
|
+
|
20
|
+
response = self.class.get(
|
21
|
+
"/oauth/access_token",
|
22
|
+
:query => {
|
23
|
+
:client_id => @app_id,
|
24
|
+
:client_secret => @secret,
|
25
|
+
:grant_type => "client_credentials"
|
26
|
+
}
|
27
|
+
)
|
28
|
+
|
29
|
+
if response.code != 200
|
30
|
+
FacebookTestAccounts.die("unable to fetch access token: #{response['error']['message']}")
|
31
|
+
end
|
32
|
+
|
33
|
+
unless match = response.match(/^access_token\=(.+)$/)
|
34
|
+
FacebookTestAccounts.die("unable to fetch access token: token not present in response.")
|
35
|
+
end
|
36
|
+
|
37
|
+
return match[1]
|
38
|
+
end
|
39
|
+
|
40
|
+
def create_test_account(access_token)
|
41
|
+
response = self.class.get(
|
42
|
+
"/#{@app_id}/accounts/test-users",
|
43
|
+
:query => {
|
44
|
+
:installed => @installed,
|
45
|
+
:permissions => @permissions,
|
46
|
+
:method => "post",
|
47
|
+
:access_token => access_token
|
48
|
+
}
|
49
|
+
)
|
50
|
+
|
51
|
+
unless response.code == 200
|
52
|
+
FacebookTestAccounts.die("unable to create test account: #{response['error']['message']}")
|
53
|
+
end
|
54
|
+
|
55
|
+
return response
|
56
|
+
end
|
57
|
+
|
58
|
+
def print_account_info(response)
|
59
|
+
|
60
|
+
info = ""
|
61
|
+
|
62
|
+
info << "" + "\n"
|
63
|
+
info << " id:\t#{response['id']}" + "\n"
|
64
|
+
info << "login_url:\t#{response['login_url']}" + "\n"
|
65
|
+
info << " email:\t#{response['email']}" + "\n"
|
66
|
+
info << " password:\t#{response['password']}" + "\n"
|
67
|
+
info << "" + "\n"
|
68
|
+
|
69
|
+
$stdout.puts(info)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module FacebookTestAccounts
|
2
|
+
class Bin
|
3
|
+
def self.run
|
4
|
+
AccountCreator.new(parseopts).create_account
|
5
|
+
end
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def self.parseopts
|
10
|
+
opts = Trollop::options do
|
11
|
+
|
12
|
+
opt :app_id, "your facebook application id", :type => :string
|
13
|
+
opt :secret, "your facebook application secret", :type => :string
|
14
|
+
|
15
|
+
opt :installed, "whether the new test user has already installed your app", :default => true
|
16
|
+
opt :permissions, "a comma-separated list of extended permissions (http://developers.facebook.com/docs/authentication/permissions). your app is granted these permissions for the new test user if installed is true.", :default => "publish_stream"
|
17
|
+
end
|
18
|
+
|
19
|
+
Trollop::die :app_id, "must be specified" unless opts[:app_id]
|
20
|
+
Trollop::die :secret, "must be specified" unless opts[:secret]
|
21
|
+
|
22
|
+
return opts
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'trollop'
|
2
|
+
require 'httparty'
|
3
|
+
require 'lib/facebook_test_accounts/account_creator'
|
4
|
+
require 'lib/facebook_test_accounts/bin'
|
5
|
+
|
6
|
+
module FacebookTestAccounts
|
7
|
+
def self.die(msg, status = 1)
|
8
|
+
$stderr.puts "\n\n#{$0.split(/\//).last}: #{msg}\n"
|
9
|
+
exit(status)
|
10
|
+
end
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: facebook_test_accounts
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Peter Brindisi
|
14
|
+
- frestyl
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2011-06-21 00:00:00 +02:00
|
20
|
+
default_executable:
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: trollop
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 3
|
31
|
+
segments:
|
32
|
+
- 0
|
33
|
+
version: "0"
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: httparty
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
version: "0"
|
48
|
+
type: :runtime
|
49
|
+
version_requirements: *id002
|
50
|
+
description: Easily create test accounts for your facebook app
|
51
|
+
email:
|
52
|
+
- npj@frestyl.com
|
53
|
+
- info@frestyl.com
|
54
|
+
executables:
|
55
|
+
- facebook_test_accounts
|
56
|
+
extensions: []
|
57
|
+
|
58
|
+
extra_rdoc_files: []
|
59
|
+
|
60
|
+
files:
|
61
|
+
- .gitignore
|
62
|
+
- Gemfile
|
63
|
+
- MIT-LICENSE
|
64
|
+
- README.markdown
|
65
|
+
- Rakefile
|
66
|
+
- bin/facebook_test_accounts
|
67
|
+
- facebook_test_accounts.gemspec
|
68
|
+
- lib/facebook_test_accounts.rb
|
69
|
+
- lib/facebook_test_accounts/account_creator.rb
|
70
|
+
- lib/facebook_test_accounts/bin.rb
|
71
|
+
- lib/facebook_test_accounts/version.rb
|
72
|
+
has_rdoc: true
|
73
|
+
homepage: https://github.com/frestyl/facebook_test_accounts
|
74
|
+
licenses: []
|
75
|
+
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
hash: 3
|
87
|
+
segments:
|
88
|
+
- 0
|
89
|
+
version: "0"
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
hash: 3
|
96
|
+
segments:
|
97
|
+
- 0
|
98
|
+
version: "0"
|
99
|
+
requirements: []
|
100
|
+
|
101
|
+
rubyforge_project: facebook_test_accounts
|
102
|
+
rubygems_version: 1.5.2
|
103
|
+
signing_key:
|
104
|
+
specification_version: 3
|
105
|
+
summary: Easily create test accounts for your facebook app
|
106
|
+
test_files: []
|
107
|
+
|