Class: FBGraph::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/fbgraph/client.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Client) initialize(options = {})



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fbgraph/client.rb', line 7

def initialize(options = {})
  @client_id = options[:client_id] || FBGraph.config[:client_id]
  @secret_id = options[:secret_id] || FBGraph.config[:secret_id]
  @ca_file = options[:ca_file] || FBGraph.config[:ca_file] || default_ca_file
  @facebook_uri = options[:facebook_uri] || 'https://graph.facebook.com'
  @consumer = RestClient::Resource.new(@facebook_uri, rest_client_ssl_options)
  @access_token = options.fetch :token, nil
  @auth = OAuth2::AccessToken.new(oauth_client, @access_token)
  @logger = options[:logger] || FBGraph::Logger
  return true
end

Instance Attribute Details

- (Object) access_token

Returns the value of attribute access_token



5
6
7
# File 'lib/fbgraph/client.rb', line 5

def access_token
  @access_token
end

- (Object) auth

Returns the value of attribute auth



5
6
7
# File 'lib/fbgraph/client.rb', line 5

def auth
  @auth
end

- (Object) client_id

Returns the value of attribute client_id



5
6
7
# File 'lib/fbgraph/client.rb', line 5

def client_id
  @client_id
end

- (Object) consumer

Returns the value of attribute consumer



5
6
7
# File 'lib/fbgraph/client.rb', line 5

def consumer
  @consumer
end

- (Object) facebook_uri

Returns the value of attribute facebook_uri



5
6
7
# File 'lib/fbgraph/client.rb', line 5

def facebook_uri
  @facebook_uri
end

- (Object) logger

Returns the value of attribute logger



5
6
7
# File 'lib/fbgraph/client.rb', line 5

def logger
  @logger
end

- (Object) secret_id

Returns the value of attribute secret_id



5
6
7
# File 'lib/fbgraph/client.rb', line 5

def secret_id
  @secret_id
end

Instance Method Details

- (Object) authorization



25
26
27
# File 'lib/fbgraph/client.rb', line 25

def authorization
  FBGraph::Authorization.new(self)
end

- (Object) default_ca_file



65
66
67
# File 'lib/fbgraph/client.rb', line 65

def default_ca_file
  File.join(File.dirname(__FILE__), 'cacert.pem')
end

- (Object) fql



41
42
43
# File 'lib/fbgraph/client.rb', line 41

def fql
  FBGraph::FQL.new(self)
end

- (Object) oauth_client



49
50
51
52
53
54
55
# File 'lib/fbgraph/client.rb', line 49

def oauth_client
  OAuth2::Client.new(client_id, secret_id,
      :site => { :url => facebook_uri },
      :token_url => '/oauth/access_token',
      :authorize_url => '/oauth/authorize',
      :ssl => oauth_client_ssl_options)
end

- (Object) oauth_client_ssl_options



57
58
59
# File 'lib/fbgraph/client.rb', line 57

def oauth_client_ssl_options
  { :ca_file => @ca_file, :verify => OpenSSL::SSL::VERIFY_PEER }
end

- (Object) realtime



37
38
39
# File 'lib/fbgraph/client.rb', line 37

def realtime
  FBGraph::Realtime.new(self)
end

- (Object) rest_client_ssl_options



61
62
63
# File 'lib/fbgraph/client.rb', line 61

def rest_client_ssl_options
  { :ssl_ca_file => @ca_file, :verify_ssl => OpenSSL::SSL::VERIFY_PEER }
end

- (Object) search



33
34
35
# File 'lib/fbgraph/client.rb', line 33

def search
  FBGraph::Search.new(self)
end

- (Object) selection



29
30
31
# File 'lib/fbgraph/client.rb', line 29

def selection
  FBGraph::Selection.new(self)
end

- (Object) set_token(new_token)



19
20
21
22
23
# File 'lib/fbgraph/client.rb', line 19

def set_token(new_token)
  @access_token = new_token
  @auth = OAuth2::AccessToken.new(oauth_client, @access_token)
  new_token
end

- (Object) timeline



45
46
47
# File 'lib/fbgraph/client.rb', line 45

def timeline
  FBGraph::Timeline.new(self)
end