Class: FBGraph::Client
- Inherits:
-
Object
- Object
- FBGraph::Client
- Defined in:
- lib/fbgraph/client.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#auth ⇒ Object
Returns the value of attribute auth.
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#consumer ⇒ Object
Returns the value of attribute consumer.
-
#facebook_uri ⇒ Object
Returns the value of attribute facebook_uri.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#secret_id ⇒ Object
Returns the value of attribute secret_id.
Instance Method Summary collapse
- #authorization ⇒ Object
- #default_ca_file ⇒ Object
- #fql ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #oauth_client ⇒ Object
- #oauth_client_ssl_options ⇒ Object
- #realtime ⇒ Object
- #rest_client_ssl_options ⇒ Object
- #search ⇒ Object
- #selection ⇒ Object
- #set_token(new_token) ⇒ Object
- #timeline ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/fbgraph/client.rb', line 7 def initialize( = {}) @client_id = [:client_id] || FBGraph.config[:client_id] @secret_id = [:secret_id] || FBGraph.config[:secret_id] @ca_file = [:ca_file] || FBGraph.config[:ca_file] || default_ca_file @facebook_uri = [:facebook_uri] || 'https://graph.facebook.com' @consumer = RestClient::Resource.new(@facebook_uri, ) @access_token = .fetch :token, nil @auth = OAuth2::AccessToken.new(oauth_client, @access_token) @logger = [:logger] || FBGraph::Logger return true end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
5 6 7 |
# File 'lib/fbgraph/client.rb', line 5 def access_token @access_token end |
#auth ⇒ Object
Returns the value of attribute auth.
5 6 7 |
# File 'lib/fbgraph/client.rb', line 5 def auth @auth end |
#client_id ⇒ Object
Returns the value of attribute client_id.
5 6 7 |
# File 'lib/fbgraph/client.rb', line 5 def client_id @client_id end |
#consumer ⇒ Object
Returns the value of attribute consumer.
5 6 7 |
# File 'lib/fbgraph/client.rb', line 5 def consumer @consumer end |
#facebook_uri ⇒ Object
Returns the value of attribute facebook_uri.
5 6 7 |
# File 'lib/fbgraph/client.rb', line 5 def facebook_uri @facebook_uri end |
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/fbgraph/client.rb', line 5 def logger @logger end |
#secret_id ⇒ Object
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
#authorization ⇒ Object
25 26 27 |
# File 'lib/fbgraph/client.rb', line 25 def FBGraph::Authorization.new(self) end |
#default_ca_file ⇒ Object
65 66 67 |
# File 'lib/fbgraph/client.rb', line 65 def default_ca_file File.join(File.dirname(__FILE__), 'cacert.pem') end |
#oauth_client ⇒ Object
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 => ) end |
#oauth_client_ssl_options ⇒ Object
57 58 59 |
# File 'lib/fbgraph/client.rb', line 57 def { :ca_file => @ca_file, :verify => OpenSSL::SSL::VERIFY_PEER } end |
#realtime ⇒ Object
37 38 39 |
# File 'lib/fbgraph/client.rb', line 37 def realtime FBGraph::Realtime.new(self) end |
#rest_client_ssl_options ⇒ Object
61 62 63 |
# File 'lib/fbgraph/client.rb', line 61 def { :ssl_ca_file => @ca_file, :verify_ssl => OpenSSL::SSL::VERIFY_PEER } end |
#search ⇒ Object
33 34 35 |
# File 'lib/fbgraph/client.rb', line 33 def search FBGraph::Search.new(self) end |
#selection ⇒ Object
29 30 31 |
# File 'lib/fbgraph/client.rb', line 29 def selection FBGraph::Selection.new(self) end |
#set_token(new_token) ⇒ Object
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 |