Class: FacebookOAuth::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/facebook_oauth/client.rb,
lib/facebook_oauth/objects.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



6
7
8
9
10
11
# File 'lib/facebook_oauth/client.rb', line 6

def initialize(options = {})
  @application_id = options[:application_id]
  @application_secret = options[:application_secret]
  @callback = options[:callback]
  @token = options[:token]
end

Instance Method Details

#album(id) ⇒ Object



8
9
10
# File 'lib/facebook_oauth/objects.rb', line 8

def album(id)
  FacebookOAuth::FacebookObject.new(id, self)
end

#authorize(options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/facebook_oauth/client.rb', line 22

def authorize(options = {})
  @access_token ||= client.auth_code.get_token(
    options[:code],
    :redirect_uri => options[:callback] || @callback,
    :parse => :query
  )
  
  @token = @access_token.token
  @access_token
end

#authorize_url(options = {}) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/facebook_oauth/client.rb', line 13

def authorize_url(options = {})
  options[:scope] ||= 'offline_access,publish_stream'
  client.auth_code.authorize_url(
    :client_id => @application_id,
    :redirect_uri => options[:callback] || @callback,
    :scope => options[:scope]
  )
end

#event(id) ⇒ Object



12
13
14
# File 'lib/facebook_oauth/objects.rb', line 12

def event(id)
  FacebookOAuth::FacebookObject.new(id, self)
end

#group(id) ⇒ Object



16
17
18
# File 'lib/facebook_oauth/objects.rb', line 16

def group(id)
  FacebookOAuth::FacebookObject.new(id, self)
end


20
21
22
# File 'lib/facebook_oauth/objects.rb', line 20

def link(id)
  FacebookOAuth::FacebookObject.new(id, self)
end

#me(id = 'me') ⇒ Object



4
5
6
# File 'lib/facebook_oauth/objects.rb', line 4

def me(id = 'me')
  FacebookOAuth::FacebookObject.new(id, self)
end

#note(id) ⇒ Object



24
25
26
# File 'lib/facebook_oauth/objects.rb', line 24

def note(id)
  FacebookOAuth::FacebookObject.new(id, self)
end

#page(id) ⇒ Object



28
29
30
# File 'lib/facebook_oauth/objects.rb', line 28

def page(id)
  FacebookOAuth::FacebookObject.new(id, self)
end

#photo(id) ⇒ Object



32
33
34
# File 'lib/facebook_oauth/objects.rb', line 32

def photo(id)
  FacebookOAuth::FacebookObject.new(id, self)
end

#post(id) ⇒ Object



36
37
38
# File 'lib/facebook_oauth/objects.rb', line 36

def post(id)
  FacebookOAuth::FacebookObject.new(id, self)
end

#status(id) ⇒ Object



40
41
42
# File 'lib/facebook_oauth/objects.rb', line 40

def status(id)
  FacebookOAuth::FacebookObject.new(id, self)
end

#user(id) ⇒ Object



44
45
46
# File 'lib/facebook_oauth/objects.rb', line 44

def user(id)
  FacebookOAuth::FacebookObject.new(id, self)
end

#video(id) ⇒ Object



48
49
50
# File 'lib/facebook_oauth/objects.rb', line 48

def video(id)
  FacebookOAuth::FacebookObject.new(id, self)
end