fbgraph 0.1.4 → 0.1.6
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.tar.gz.sig +0 -0
- data/Manifest +2 -0
- data/README.textile +19 -2
- data/Rakefile +1 -1
- data/fbgraph.gemspec +6 -6
- data/lib/fbgraph.rb +24 -1
- data/lib/fbgraph/authorization.rb +34 -0
- data/lib/fbgraph/base.rb +1 -0
- data/lib/fbgraph/canvas.rb +34 -0
- data/lib/fbgraph/client.rb +29 -32
- data/lib/fbgraph/selection.rb +1 -1
- metadata +24 -5
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/Manifest
CHANGED
data/README.textile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
h2. FBGRaph (0.1.
|
1
|
+
h2. FBGRaph (0.1.4)
|
2
2
|
|
3
3
|
p. Facebook Open Graph API Gem.
|
4
4
|
|
@@ -53,6 +53,10 @@ notextile. <code>client.selection.user('id').videos.offset(10).info</code>
|
|
53
53
|
|
54
54
|
notextile. <code>client.search.query('q').on('users').limit(20).info</code>
|
55
55
|
|
56
|
+
h3. Rails config file
|
57
|
+
|
58
|
+
h2. TODO
|
59
|
+
|
56
60
|
h3. Authorization
|
57
61
|
|
58
62
|
h4. client.authorization.authorize_url
|
@@ -67,6 +71,15 @@ p. process the callback and returns the access token
|
|
67
71
|
|
68
72
|
notextile. <code> access_token = client.authorization.process_callback(params[:code], :redirect_uri => callback_url)</code>
|
69
73
|
|
74
|
+
h3. Exchange Sessions
|
75
|
+
|
76
|
+
h2. TODO
|
77
|
+
|
78
|
+
h3. Canvas
|
79
|
+
|
80
|
+
|
81
|
+
h2. TODO
|
82
|
+
|
70
83
|
|
71
84
|
h3. Selection
|
72
85
|
|
@@ -224,7 +237,7 @@ h2. Contributions
|
|
224
237
|
p. Just do a pull request with the repo in sync.
|
225
238
|
|
226
239
|
|
227
|
-
h2. Contributors
|
240
|
+
h2. Contributors List
|
228
241
|
|
229
242
|
"Victor Costan":http://github.com/costan
|
230
243
|
|
@@ -232,3 +245,7 @@ h2. Contributors
|
|
232
245
|
|
233
246
|
"Florent Guilleux":http://github.com/Florent2
|
234
247
|
|
248
|
+
"Jan De Poorter":http://github.com/DefV
|
249
|
+
|
250
|
+
"Thilo-Alexander Ginkel":http://github.com/ginkel
|
251
|
+
|
data/Rakefile
CHANGED
data/fbgraph.gemspec
CHANGED
@@ -2,21 +2,21 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{fbgraph}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.6"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Nicolas Santa"]
|
9
9
|
s.cert_chain = ["/home/nicolas/certs/gem-public_cert.pem"]
|
10
|
-
s.date = %q{2010-
|
10
|
+
s.date = %q{2010-09-07}
|
11
11
|
s.description = %q{A Gem for Facebook Open Graph API}
|
12
12
|
s.email = %q{nicolas55ar@gmail.com}
|
13
|
-
s.extra_rdoc_files = ["README", "README.textile", "TODO.list", "lib/fbgraph.rb", "lib/fbgraph/authorization.rb", "lib/fbgraph/base.rb", "lib/fbgraph/client.rb", "lib/fbgraph/realtime.rb", "lib/fbgraph/search.rb", "lib/fbgraph/selection.rb"]
|
14
|
-
s.files = ["Manifest", "README", "README.textile", "Rakefile", "TODO.list", "lib/fbgraph.rb", "lib/fbgraph/authorization.rb", "lib/fbgraph/base.rb", "lib/fbgraph/client.rb", "lib/fbgraph/realtime.rb", "lib/fbgraph/search.rb", "lib/fbgraph/selection.rb", "specs/lib/fbauth/authorization_spec.rb", "specs/lib/fbauth/base_spec.rb", "specs/lib/fbauth/client_spec.rb", "specs/lib/fbauth/realtime_spec.rb", "specs/lib/fbauth/search_spec.rb", "specs/lib/fbauth/selection_spec.rb", "specs/spec_helper.rb"
|
13
|
+
s.extra_rdoc_files = ["README", "README.textile", "TODO.list", "lib/fbgraph.rb", "lib/fbgraph/authorization.rb", "lib/fbgraph/base.rb", "lib/fbgraph/canvas.rb", "lib/fbgraph/client.rb", "lib/fbgraph/realtime.rb", "lib/fbgraph/search.rb", "lib/fbgraph/selection.rb"]
|
14
|
+
s.files = ["Manifest", "README", "README.textile", "Rakefile", "TODO.list", "fbgraph.gemspec", "lib/fbgraph.rb", "lib/fbgraph/authorization.rb", "lib/fbgraph/base.rb", "lib/fbgraph/canvas.rb", "lib/fbgraph/client.rb", "lib/fbgraph/realtime.rb", "lib/fbgraph/search.rb", "lib/fbgraph/selection.rb", "specs/lib/fbauth/authorization_spec.rb", "specs/lib/fbauth/base_spec.rb", "specs/lib/fbauth/client_spec.rb", "specs/lib/fbauth/realtime_spec.rb", "specs/lib/fbauth/search_spec.rb", "specs/lib/fbauth/selection_spec.rb", "specs/spec_helper.rb"]
|
15
15
|
s.homepage = %q{http://github.com/nsanta/fbgraph}
|
16
16
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Fbgraph", "--main", "README"]
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
s.rubyforge_project = %q{fbgraph}
|
19
|
-
s.rubygems_version = %q{1.3.
|
19
|
+
s.rubygems_version = %q{1.3.7}
|
20
20
|
s.signing_key = %q{/home/nicolas/certs/gem-private_key.pem}
|
21
21
|
s.summary = %q{A Gem for Facebook Open Graph API}
|
22
22
|
|
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
25
25
|
s.specification_version = 3
|
26
26
|
|
27
|
-
if Gem::Version.new(Gem::
|
27
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
28
28
|
s.add_runtime_dependency(%q<oauth2>, [">= 0"])
|
29
29
|
s.add_runtime_dependency(%q<json>, [">= 0"])
|
30
30
|
s.add_runtime_dependency(%q<hashie>, [">= 0"])
|
data/lib/fbgraph.rb
CHANGED
@@ -3,7 +3,8 @@ require 'json'
|
|
3
3
|
require 'hashie'
|
4
4
|
require 'rest_client'
|
5
5
|
require 'uri'
|
6
|
-
|
6
|
+
require "base64"
|
7
|
+
require "openssl"
|
7
8
|
|
8
9
|
require 'fbgraph/client'
|
9
10
|
require 'fbgraph/base'
|
@@ -11,3 +12,25 @@ require 'fbgraph/authorization'
|
|
11
12
|
require 'fbgraph/selection'
|
12
13
|
require 'fbgraph/search'
|
13
14
|
require 'fbgraph/realtime'
|
15
|
+
require 'fbgraph/canvas'
|
16
|
+
|
17
|
+
module FBGraph
|
18
|
+
@config = {}
|
19
|
+
|
20
|
+
class << self
|
21
|
+
|
22
|
+
def load_config(yaml_file)
|
23
|
+
return false unless File.exist?(yaml_file)
|
24
|
+
cfg = YAML::load(File.open(yaml_file))
|
25
|
+
if defined? Rails
|
26
|
+
cfg = cfg[Rails.env]
|
27
|
+
end
|
28
|
+
cfg
|
29
|
+
end
|
30
|
+
|
31
|
+
def config
|
32
|
+
@config ||= load_config(File.join(Rails.root , 'config' , 'facebook.yml')).freeze
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -7,14 +7,48 @@ module FBGraph
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def authorize_url(params = {})
|
10
|
+
params = { :redirect_uri => FBGraph.config[:canvas_url] }.merge(params)
|
10
11
|
@client.oauth_client.web_server.authorize_url(params)
|
11
12
|
end
|
12
13
|
|
13
14
|
|
14
15
|
def process_callback(code, options = {})
|
16
|
+
options = { :redirect_uri => FBGraph.config[:canvas_url] }.merge(options)
|
15
17
|
@client.auth = @client.oauth_client.web_server.get_access_token(code, options)
|
16
18
|
@client.access_token = @client.auth.token
|
17
19
|
end
|
20
|
+
|
21
|
+
def upgrade_session!(key)
|
22
|
+
token = upgrade_session_keys(key).first
|
23
|
+
@client.access_token = token
|
24
|
+
end
|
25
|
+
|
26
|
+
def upgrade_session_keys(*keys)
|
27
|
+
tokens = @client.oauth_client.request(:get, '/oauth/exchange_sessions', {
|
28
|
+
:client_id => @client.client_id,
|
29
|
+
:client_secret => @client.secret_id,
|
30
|
+
:type => 'client_cred',
|
31
|
+
:sessions => keys.flatten.join(',')
|
32
|
+
})
|
33
|
+
JSON.parse(tokens).map { |hash| hash['access_token'] if hash}
|
34
|
+
end
|
35
|
+
|
36
|
+
def upgrade_session(key)
|
37
|
+
token = upgrade_session_keys(key).first
|
38
|
+
@client.access_token = token['access_token']
|
39
|
+
token
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
def exchange_sessions(*keys)
|
44
|
+
tokens = @client.oauth_client.request(:get, '/oauth/exchange_sessions', {
|
45
|
+
:client_id => @client.client_id,
|
46
|
+
:client_secret => @client.secret_id,
|
47
|
+
:type => 'client_cred',
|
48
|
+
:sessions => keys.flatten.join(',')
|
49
|
+
})
|
50
|
+
JSON.parse(tokens)
|
51
|
+
end
|
18
52
|
|
19
53
|
end
|
20
54
|
end
|
data/lib/fbgraph/base.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
module Fbgraph
|
2
|
+
|
3
|
+
class Canvas
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def parse_signed_request(secret_id,request)
|
7
|
+
encoded_sig, payload = request.split('.', 2)
|
8
|
+
sig = ""
|
9
|
+
urldecode64(encoded_sig).each_byte { |b|
|
10
|
+
sig << "%02x" % b
|
11
|
+
}
|
12
|
+
data = JSON.parse(urldecode64(payload))
|
13
|
+
if data['algorithm'].to_s.upcase != 'HMAC-SHA256'
|
14
|
+
raise "Bad signature algorithm: %s" % data['algorithm']
|
15
|
+
end
|
16
|
+
expected_sig = OpenSSL::HMAC.hexdigest('sha256', secret_id, payload)
|
17
|
+
if expected_sig != sig
|
18
|
+
raise "Bad signature"
|
19
|
+
end
|
20
|
+
data
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def urldecode64(str)
|
26
|
+
encoded_str = str.gsub('-','+').gsub('_','/')
|
27
|
+
encoded_str += '=' while !(encoded_str.size % 4).zero?
|
28
|
+
Base64.decode64(encoded_str)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
data/lib/fbgraph/client.rb
CHANGED
@@ -1,39 +1,36 @@
|
|
1
1
|
module FBGraph
|
2
2
|
|
3
3
|
class Client
|
4
|
-
attr_accessor :client_id , :secret_id , :facebook_uri , :access_token , :consumer , :auth
|
5
|
-
|
6
|
-
|
7
|
-
def initialize(options)
|
8
|
-
@client_id , @secret_id = options[:client_id] , options[:secret_id]
|
9
|
-
@facebook_uri = 'https://graph.facebook.com'
|
10
|
-
@access_token = options[:token]
|
11
|
-
@consumer = RestClient::Resource.new(@facebook_uri)
|
12
|
-
@auth = OAuth2::AccessToken.new(oauth_client , @access_token)
|
13
|
-
return true
|
14
|
-
end
|
15
|
-
|
16
|
-
|
17
|
-
def authorization
|
18
|
-
FBGraph::Authorization.new(self)
|
19
|
-
end
|
20
|
-
|
21
|
-
def selection
|
22
|
-
FBGraph::Selection.new(self)
|
23
|
-
end
|
24
|
-
|
25
|
-
def search
|
26
|
-
FBGraph::Search.new(self)
|
27
|
-
end
|
28
4
|
|
29
|
-
|
30
|
-
FBGraph::Realtime.new(self)
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
def oauth_client
|
35
|
-
OAuth2::Client.new(client_id, secret_id, :site => facebook_uri)
|
36
|
-
end
|
5
|
+
attr_accessor :client_id , :secret_id , :facebook_uri , :access_token , :consumer , :auth
|
37
6
|
|
7
|
+
def initialize(options = {})
|
8
|
+
@client_id, @secret_id = options[:client_id] || FBGraph.config[:client_id], options[:secret_id] || FBGraph.config[:secret_id]
|
9
|
+
@facebook_uri = 'https://graph.facebook.com'
|
10
|
+
@consumer = RestClient::Resource.new(@facebook_uri)
|
11
|
+
@auth = OAuth2::AccessToken.new(oauth_client , @access_token)
|
12
|
+
return true
|
13
|
+
end
|
14
|
+
|
15
|
+
def authorization
|
16
|
+
FBGraph::Authorization.new(self)
|
17
|
+
end
|
18
|
+
|
19
|
+
def selection
|
20
|
+
FBGraph::Selection.new(self)
|
21
|
+
end
|
22
|
+
|
23
|
+
def search
|
24
|
+
FBGraph::Search.new(self)
|
25
|
+
end
|
26
|
+
|
27
|
+
def realtime
|
28
|
+
FBGraph::Realtime.new(self)
|
29
|
+
end
|
30
|
+
|
31
|
+
def oauth_client
|
32
|
+
OAuth2::Client.new(client_id, secret_id, :site => facebook_uri)
|
33
|
+
end
|
34
|
+
|
38
35
|
end
|
39
36
|
end
|
data/lib/fbgraph/selection.rb
CHANGED
@@ -41,7 +41,7 @@ module FBGraph
|
|
41
41
|
def picture
|
42
42
|
uri = @client.facebook_uri + build_open_graph_path(@objects , 'picture')
|
43
43
|
return uri unless @client.consumer
|
44
|
-
uri + '?access_token=' + @client.
|
44
|
+
uri + '?access_token=' + @client.access_token
|
45
45
|
end
|
46
46
|
|
47
47
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fbgraph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Nicolas Santa
|
@@ -35,16 +36,18 @@ cert_chain:
|
|
35
36
|
urUszHKBS/vEBMuC
|
36
37
|
-----END CERTIFICATE-----
|
37
38
|
|
38
|
-
date: 2010-
|
39
|
+
date: 2010-09-07 00:00:00 -03:00
|
39
40
|
default_executable:
|
40
41
|
dependencies:
|
41
42
|
- !ruby/object:Gem::Dependency
|
42
43
|
name: oauth2
|
43
44
|
prerelease: false
|
44
45
|
requirement: &id001 !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
45
47
|
requirements:
|
46
48
|
- - ">="
|
47
49
|
- !ruby/object:Gem::Version
|
50
|
+
hash: 3
|
48
51
|
segments:
|
49
52
|
- 0
|
50
53
|
version: "0"
|
@@ -54,9 +57,11 @@ dependencies:
|
|
54
57
|
name: json
|
55
58
|
prerelease: false
|
56
59
|
requirement: &id002 !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
57
61
|
requirements:
|
58
62
|
- - ">="
|
59
63
|
- !ruby/object:Gem::Version
|
64
|
+
hash: 3
|
60
65
|
segments:
|
61
66
|
- 0
|
62
67
|
version: "0"
|
@@ -66,9 +71,11 @@ dependencies:
|
|
66
71
|
name: hashie
|
67
72
|
prerelease: false
|
68
73
|
requirement: &id003 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
69
75
|
requirements:
|
70
76
|
- - ">="
|
71
77
|
- !ruby/object:Gem::Version
|
78
|
+
hash: 3
|
72
79
|
segments:
|
73
80
|
- 0
|
74
81
|
version: "0"
|
@@ -78,9 +85,11 @@ dependencies:
|
|
78
85
|
name: rest-client
|
79
86
|
prerelease: false
|
80
87
|
requirement: &id004 !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
81
89
|
requirements:
|
82
90
|
- - ">="
|
83
91
|
- !ruby/object:Gem::Version
|
92
|
+
hash: 3
|
84
93
|
segments:
|
85
94
|
- 0
|
86
95
|
version: "0"
|
@@ -90,9 +99,11 @@ dependencies:
|
|
90
99
|
name: echoe
|
91
100
|
prerelease: false
|
92
101
|
requirement: &id005 !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
93
103
|
requirements:
|
94
104
|
- - ">="
|
95
105
|
- !ruby/object:Gem::Version
|
106
|
+
hash: 3
|
96
107
|
segments:
|
97
108
|
- 0
|
98
109
|
version: "0"
|
@@ -102,9 +113,11 @@ dependencies:
|
|
102
113
|
name: rspec
|
103
114
|
prerelease: false
|
104
115
|
requirement: &id006 !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
105
117
|
requirements:
|
106
118
|
- - ">="
|
107
119
|
- !ruby/object:Gem::Version
|
120
|
+
hash: 3
|
108
121
|
segments:
|
109
122
|
- 0
|
110
123
|
version: "0"
|
@@ -123,6 +136,7 @@ extra_rdoc_files:
|
|
123
136
|
- lib/fbgraph.rb
|
124
137
|
- lib/fbgraph/authorization.rb
|
125
138
|
- lib/fbgraph/base.rb
|
139
|
+
- lib/fbgraph/canvas.rb
|
126
140
|
- lib/fbgraph/client.rb
|
127
141
|
- lib/fbgraph/realtime.rb
|
128
142
|
- lib/fbgraph/search.rb
|
@@ -133,9 +147,11 @@ files:
|
|
133
147
|
- README.textile
|
134
148
|
- Rakefile
|
135
149
|
- TODO.list
|
150
|
+
- fbgraph.gemspec
|
136
151
|
- lib/fbgraph.rb
|
137
152
|
- lib/fbgraph/authorization.rb
|
138
153
|
- lib/fbgraph/base.rb
|
154
|
+
- lib/fbgraph/canvas.rb
|
139
155
|
- lib/fbgraph/client.rb
|
140
156
|
- lib/fbgraph/realtime.rb
|
141
157
|
- lib/fbgraph/search.rb
|
@@ -147,7 +163,6 @@ files:
|
|
147
163
|
- specs/lib/fbauth/search_spec.rb
|
148
164
|
- specs/lib/fbauth/selection_spec.rb
|
149
165
|
- specs/spec_helper.rb
|
150
|
-
- fbgraph.gemspec
|
151
166
|
has_rdoc: true
|
152
167
|
homepage: http://github.com/nsanta/fbgraph
|
153
168
|
licenses: []
|
@@ -163,16 +178,20 @@ rdoc_options:
|
|
163
178
|
require_paths:
|
164
179
|
- lib
|
165
180
|
required_ruby_version: !ruby/object:Gem::Requirement
|
181
|
+
none: false
|
166
182
|
requirements:
|
167
183
|
- - ">="
|
168
184
|
- !ruby/object:Gem::Version
|
185
|
+
hash: 3
|
169
186
|
segments:
|
170
187
|
- 0
|
171
188
|
version: "0"
|
172
189
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
|
+
none: false
|
173
191
|
requirements:
|
174
192
|
- - ">="
|
175
193
|
- !ruby/object:Gem::Version
|
194
|
+
hash: 11
|
176
195
|
segments:
|
177
196
|
- 1
|
178
197
|
- 2
|
@@ -180,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
199
|
requirements: []
|
181
200
|
|
182
201
|
rubyforge_project: fbgraph
|
183
|
-
rubygems_version: 1.3.
|
202
|
+
rubygems_version: 1.3.7
|
184
203
|
signing_key:
|
185
204
|
specification_version: 3
|
186
205
|
summary: A Gem for Facebook Open Graph API
|
metadata.gz.sig
CHANGED
Binary file
|