Class: Fobos::GraphAPI::Users
- Inherits:
-
Object
- Object
- Fobos::GraphAPI::Users
- Includes:
- HTTParty
- Defined in:
- lib/fobos/graph_api/users.rb
Constant Summary collapse
- FB_URI =
Store Facebook default URL
'https://www.facebook.com'- GRAPH_URI =
Store Facebook Graph API URL
'https://graph.facebook.com'
Instance Attribute Summary collapse
-
#access_token ⇒ Object
You can get access token with Fobos::GraphAPI::Oauth.
Instance Method Summary collapse
-
#get_request(options = {}) ⇒ Object
Provides call of get_request_url.
-
#get_request_url(options = {}) ⇒ Object
Generate link for getting user’s data with options.
-
#initialize(access_token) ⇒ Users
constructor
Need access token for making calls.
-
#post_request(options = {}) ⇒ Object
Provides call of post_request_url.
-
#post_request_url(options = {}) ⇒ Object
Generate link for post request (publishing) for user.
Constructor Details
#initialize(access_token) ⇒ Users
Need access token for making calls.
17 18 19 |
# File 'lib/fobos/graph_api/users.rb', line 17 def initialize(access_token) @access_token = access_token end |
Instance Attribute Details
#access_token ⇒ Object
You can get access token with Fobos::GraphAPI::Oauth.
9 10 11 |
# File 'lib/fobos/graph_api/users.rb', line 9 def access_token @access_token end |
Instance Method Details
#get_request(options = {}) ⇒ Object
Provides call of get_request_url
47 48 49 |
# File 'lib/fobos/graph_api/users.rb', line 47 def get_request( = {}) self.class.get(get_request_url()) end |
#get_request_url(options = {}) ⇒ Object
Generate link for getting user’s data with options. Options must be a hash. You can provide value as String or Array.
E.g. Fobos::GraphAPI::Users.new(access_token).get_request_url(fields: ‘id’) will return “graph.facebook.com/v2.1/me?fields=id&access_token=some_token”
25 26 27 28 29 30 |
# File 'lib/fobos/graph_api/users.rb', line 25 def get_request_url( = {}) .(@access_token) = Options.() GRAPH_URI.to_s + '/v2.1' '/me?' + end |
#post_request(options = {}) ⇒ Object
Provides call of post_request_url
52 53 54 55 56 |
# File 'lib/fobos/graph_api/users.rb', line 52 def post_request( = {}) encoded_url = URI.encode(post_request_url()) self.class.post(URI.parse(encoded_url)) end |
#post_request_url(options = {}) ⇒ Object
Generate link for post request (publishing) for user. Options must be a hash. You can provide value as String or Array.
E.g. Fobos::GraphAPI::Users.new(access_token).post_request(message: ‘This is test message’) will return “graph.facebook.com/v2.1/me/feed?message=This is test message&access_token=some_token”
37 38 39 40 41 42 |
# File 'lib/fobos/graph_api/users.rb', line 37 def post_request_url( = {}) .(@access_token) = Options.() query = GRAPH_URI.to_s + '/v2.1' '/me/feed?' + end |