Class: OAuth::Facebook

Inherits:
Base
  • Object
show all
Defined in:
app/models/o_auth/facebook.rb

Constant Summary collapse

HOST =
'https://graph.facebook.com'
ACCESS_TOKEN_URL =
HOST + '/oauth/access_token'
DATA_URL =
HOST + '/me?fields=id,email,name,birthday,location,gender,picture'
FRIENDS_URL =
HOST + '/me/friends'

Instance Attribute Summary collapse

Attributes inherited from Base

#data, #provider

Instance Method Summary collapse

Methods inherited from Base

#get_data, #initialize

Constructor Details

This class inherits a constructor from OAuth::Base

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



9
10
11
# File 'app/models/o_auth/facebook.rb', line 9

def access_token
  @access_token
end

Instance Method Details

#get_access_tokenObject



11
12
13
14
15
# File 'app/models/o_auth/facebook.rb', line 11

def get_access_token
  response = @client.get(ACCESS_TOKEN_URL, @params)
  
  Rack::Utils.parse_query(response.body)['access_token']
end

#get_namesObject



17
18
19
# File 'app/models/o_auth/facebook.rb', line 17

def get_names
  [data[:first_name], data[:last_name]]
end