Class: Fbuser::Facebook

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
app/facebook/fbuser/facebook.rb

Instance Method Summary collapse

Constructor Details

#initializeFacebook

format :json debug_output $stdout



10
11
# File 'app/facebook/fbuser/facebook.rb', line 10

def initialize()
end

Instance Method Details

#get_long_token(short_token) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/facebook/fbuser/facebook.rb', line 13

def get_long_token(short_token)
	params = { 
		grant_type: "fb_exchange_token",
		client_id: ENV["FB_APP_ID1"],
		client_secret: ENV["FB_APP_SECRET1"],
		fb_exchange_token: short_token
	}
	headers =	{ 'Content-Type' => 'application/json' }
  response = self.class.get("/oauth/access_token", query: params, headers: headers)
  if response.code == 200
  	return parse_token(response.body)
  else
  	return ""
  end
end

#get_user_id(token) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'app/facebook/fbuser/facebook.rb', line 29

def get_user_id(token)
	options = { query:{
		fields: "id",
		access_token: token
		}
	}
	response = self.class.get("/me", options)
	return response
end