Class: Challah::Facebook::Interfaces::Koala
- Inherits:
-
Base
- Object
- Base
- Challah::Facebook::Interfaces::Koala
show all
- Defined in:
- lib/challah/facebook/interfaces/koala.rb
Instance Attribute Summary
Attributes inherited from Base
#app_id, #app_secret, #permissions
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Class Method Details
.get_access_token_for_oauth_code(code, callback_uri) ⇒ Object
9
10
11
12
|
# File 'lib/challah/facebook/interfaces/koala.rb', line 9
def self.get_access_token_for_oauth_code(code, callback_uri)
auth = new(Facebook.options).auth(callback_uri)
auth.get_access_token(code)
end
|
.get_authorization_url(callback_uri, permissions = nil) ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/challah/facebook/interfaces/koala.rb', line 53
def self.get_authorization_url(callback_uri, permissions = nil)
scope = if permissions.blank?
Facebook.permissions
else
permissions
end
scope = scope.join(',') if scope.is_a?(Array)
auth = new(Facebook.options).auth(callback_uri)
auth.url_for_oauth_code(permissions: scope)
end
|
.get_extended_token(access_token) ⇒ Object
14
15
16
17
18
|
# File 'lib/challah/facebook/interfaces/koala.rb', line 14
def self.get_extended_token(access_token)
auth = new(Facebook.options).auth
token_hash = auth.exchange_access_token_info(access_token)
token_hash.fetch('access_token')
end
|
.get_facebook_uid_from_access_token(access_token) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/challah/facebook/interfaces/koala.rb', line 20
def self.get_facebook_uid_from_access_token(access_token)
fb_user = get_user_object_from_access_token(access_token)
if fb_user
return fb_user.fetch('id').to_s
end
nil
rescue
nil
end
|
.get_user_info_from_access_token(access_token) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/challah/facebook/interfaces/koala.rb', line 32
def self.get_user_info_from_access_token(access_token)
result = {}
fb_user = get_user_object_from_access_token(access_token)
Facebook.user_fields.each do |field|
if fb_user.has_key?(field)
result[field] = fb_user[field]
else
result[field] = nil
end
end
result
end
|
.get_user_object_from_access_token(access_token) ⇒ Object
48
49
50
51
|
# File 'lib/challah/facebook/interfaces/koala.rb', line 48
def self.get_user_object_from_access_token(access_token)
graph = ::Koala::Facebook::API.new(access_token)
graph.get_object('me')
end
|
.mode ⇒ Object
5
6
7
|
# File 'lib/challah/facebook/interfaces/koala.rb', line 5
def self.mode
"koala"
end
|
Instance Method Details
#auth(callback_url = nil) ⇒ Object
66
67
68
|
# File 'lib/challah/facebook/interfaces/koala.rb', line 66
def auth(callback_url = nil)
@auth ||= ::Koala::Facebook::OAuth.new(app_id, app_secret, callback_url)
end
|