facebookcl 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/commands/base.rb +0 -2
- data/commands/help.rb +0 -2
- data/commands/info.rb +0 -2
- data/commands/picture.rb +0 -2
- data/commands/stream.rb +0 -2
- data/commands/wall.rb +0 -2
- data/facebookcl.gemspec +2 -1
- data/lib/facebook_server.rb +36 -0
- data/lib/facebookcl.rb +8 -31
- metadata +4 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.4
|
data/commands/base.rb
CHANGED
data/commands/help.rb
CHANGED
data/commands/info.rb
CHANGED
data/commands/picture.rb
CHANGED
data/commands/stream.rb
CHANGED
data/commands/wall.rb
CHANGED
data/facebookcl.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{facebookcl}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Justin Bishop"]
|
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
"commands/stream.rb",
|
34
34
|
"commands/wall.rb",
|
35
35
|
"facebookcl.gemspec",
|
36
|
+
"lib/facebook_server.rb",
|
36
37
|
"lib/facebookcl.rb"
|
37
38
|
]
|
38
39
|
s.homepage = %q{http://github.com/jubishop/facebookcl}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class FacebookAuthServer < TCPServer
|
2
|
+
def serve_and_extract_access_token_from_user_agent_flow
|
3
|
+
serve_content_and_return_request(%Q{
|
4
|
+
<script>
|
5
|
+
window.location.replace(window.location.toString().replace('#', '?'));
|
6
|
+
</script>})
|
7
|
+
|
8
|
+
request = serve_content_and_return_request(%q{
|
9
|
+
Success! You can now close this window and return to FacebookCL.
|
10
|
+
<script>
|
11
|
+
window.close();
|
12
|
+
</script>})
|
13
|
+
|
14
|
+
extract_access_token_from_request(request)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
HTTP_HEADER = "HTTP/1.1 200/OK\r\nContent-type:text/html\r\n\r\n"
|
20
|
+
|
21
|
+
def serve_content_and_return_request(content)
|
22
|
+
session = accept
|
23
|
+
session.print HTTP_HEADER
|
24
|
+
|
25
|
+
request = session.gets.strip
|
26
|
+
|
27
|
+
session.print(content)
|
28
|
+
session.close
|
29
|
+
|
30
|
+
request
|
31
|
+
end
|
32
|
+
|
33
|
+
def extract_access_token_from_request(request)
|
34
|
+
request.gsub(/^GET \/\?access_token=/, '').gsub(/ HTTP.*$/, '')
|
35
|
+
end
|
36
|
+
end
|
data/lib/facebookcl.rb
CHANGED
@@ -10,9 +10,11 @@ require 'uri'
|
|
10
10
|
# runtime dependencies
|
11
11
|
require 'json'
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
# helper libs
|
14
|
+
__DIR__ = File.dirname(__FILE__)
|
15
|
+
require __DIR__ + '/facebook_server.rb'
|
15
16
|
|
17
|
+
module FacebookCL; class << self
|
16
18
|
APP_ID = 119412046078 # FacebookCL
|
17
19
|
SERVER_PORT = 6682 # my birthday ;o)
|
18
20
|
GRAPH_URL = 'graph.facebook.com'
|
@@ -52,22 +54,11 @@ module FacebookCL; class << self
|
|
52
54
|
auth_url
|
53
55
|
end
|
54
56
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
request = serve_content(%q{
|
61
|
-
Success! You can now close this window and return to FacebookCL.
|
62
|
-
<script>
|
63
|
-
window.close();
|
64
|
-
</script>})
|
57
|
+
server = FacebookAuthServer.new(NEXT_URL, SERVER_PORT)
|
58
|
+
self.access_token =
|
59
|
+
server.serve_and_extract_access_token_from_user_agent_flow
|
60
|
+
server.close
|
65
61
|
|
66
|
-
@server.close
|
67
|
-
|
68
|
-
self.access_token = request.
|
69
|
-
gsub(/^GET \/\?access_token=/, '').
|
70
|
-
gsub(/ HTTP.*$/, '')
|
71
62
|
self.uid = get('me')['id']
|
72
63
|
|
73
64
|
puts "Saving authentication data to #{config_filename}"
|
@@ -116,18 +107,4 @@ module FacebookCL; class << self
|
|
116
107
|
value
|
117
108
|
end
|
118
109
|
end
|
119
|
-
|
120
|
-
def serve_content(content)
|
121
|
-
@server ||= TCPServer.new(NEXT_URL, SERVER_PORT)
|
122
|
-
|
123
|
-
session = @server.accept
|
124
|
-
session.print "HTTP/1.1 200/OK\r\nContent-type:text/html\r\n\r\n"
|
125
|
-
|
126
|
-
request = session.gets.strip
|
127
|
-
|
128
|
-
session.print content
|
129
|
-
session.close
|
130
|
-
|
131
|
-
request
|
132
|
-
end
|
133
110
|
end; end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: facebookcl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 4
|
10
|
+
version: 0.3.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Justin Bishop
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- commands/stream.rb
|
57
57
|
- commands/wall.rb
|
58
58
|
- facebookcl.gemspec
|
59
|
+
- lib/facebook_server.rb
|
59
60
|
- lib/facebookcl.rb
|
60
61
|
has_rdoc: true
|
61
62
|
homepage: http://github.com/jubishop/facebookcl
|