Class: FacebookPlugin
- Inherits:
-
Rubko::Plugin
- Object
- Rubko::Plugin
- FacebookPlugin
- Defined in:
- lib/rubko/plugins/facebook.rb
Instance Attribute Summary collapse
-
#home ⇒ Object
Returns the value of attribute home.
-
#id ⇒ Object
Returns the value of attribute id.
-
#secret ⇒ Object
Returns the value of attribute secret.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Attributes included from Rubko::Base
Instance Method Summary collapse
- #init ⇒ Object
-
#login(state, str) ⇒ Object
PART 2: Return user data, populate @token.
-
#start ⇒ Object
PART 1: Initiate login, ask user for permissions.
Methods inherited from Rubko::Plugin
Methods included from Rubko::Base
#camelize, #finalize, #httpGet, #initialize, #jsonParse, #loadController, #loadFile, #loadModel, #loadPlugin, #loadView, #method_missing, #uncamelize
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Rubko::Base
Instance Attribute Details
#home ⇒ Object
Returns the value of attribute home.
9 10 11 |
# File 'lib/rubko/plugins/facebook.rb', line 9 def home @home end |
#id ⇒ Object
Returns the value of attribute id.
9 10 11 |
# File 'lib/rubko/plugins/facebook.rb', line 9 def id @id end |
#secret ⇒ Object
Returns the value of attribute secret.
9 10 11 |
# File 'lib/rubko/plugins/facebook.rb', line 9 def secret @secret end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
10 11 12 |
# File 'lib/rubko/plugins/facebook.rb', line 10 def token @token end |
Instance Method Details
#init ⇒ Object
4 5 6 7 |
# File 'lib/rubko/plugins/facebook.rb', line 4 def init @home = "http://#{url.host}/" config end |
#login(state, str) ⇒ Object
PART 2: Return user data, populate @token
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rubko/plugins/facebook.rb', line 22 def login(state, str) raise 'Please supply the return value of #start to #login' unless state params = parse str return false if state != params['state'] code = params['code'] url = build 'https://graph.facebook.com/oauth/access_token', query.merge({ client_secret: secret, code: code }) @token = parse( httpGet url )['access_token'] jsonParse httpGet build 'https://graph.facebook.com/me', access_token: token end |
#start ⇒ Object
PART 1: Initiate login, ask user for permissions
13 14 15 16 17 18 19 |
# File 'lib/rubko/plugins/facebook.rb', line 13 def start SecureRandom.hex(16).tap { |state| url.redirect build 'https://www.facebook.com/dialog/oauth', query.merge({ scope: 'email,publish_stream', state: state }) } end |