fobos 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -0
- data/README.md +9 -4
- data/fobos.gemspec +1 -1
- data/lib/fobos/graph_api/hash.rb +7 -0
- data/lib/fobos/graph_api/o_auth.rb +2 -2
- data/lib/fobos/graph_api/options.rb +9 -0
- data/lib/fobos/graph_api/pages.rb +5 -5
- data/lib/fobos/graph_api/users.rb +24 -17
- data/lib/fobos/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d50d60fa119b7ff9f0336379a0798d63cbe6215
|
4
|
+
data.tar.gz: a622fa5b2572d432dd07884d2bf5ff0cdb7e7e81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb6566284b89c7a1982de84c2398ec1e2fbaf2e94045129a24688e74293af59387a0747907266fc7e59540e9cd6169f392b6cff7ff989799a5ffec98c5a902a4
|
7
|
+
data.tar.gz: f97f2d797954df718368b196520c9be8eba963c17bc210de33c692a87e34fa88ad188b53dd10e36997f33091f88e82acf081e3e15d0ea97c0bcb52ed9227baef
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Fobos
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/fobos.svg)](http://badge.fury.io/rb/fobos)
|
4
|
+
[![Build Status](https://travis-ci.org/mxgoncharov/fobos.svg?branch=master)](https://travis-ci.org/mxgoncharov/fobos)
|
5
|
+
[![Dependency Status](https://gemnasium.com/mxgoncharov/fobos.svg)](https://gemnasium.com/mxgoncharov/fobos)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/mxgoncharov/fobos/badges/gpa.svg)](https://codeclimate.com/github/mxgoncharov/fobos)
|
7
|
+
|
3
8
|
Fobos is a easy to use, based on HTTParty gem for working with Facebook Graph and REST API.
|
4
9
|
|
5
10
|
|
@@ -36,16 +41,16 @@ Then call method which generate URL for getting access code.
|
|
36
41
|
access_code_url = oauth.get_user_access_code_url
|
37
42
|
```
|
38
43
|
|
39
|
-
**
|
44
|
+
**THEN**, you need make HTTP request.
|
40
45
|
|
41
46
|
```ruby
|
42
|
-
|
47
|
+
redirect_to access_code_url
|
43
48
|
```
|
44
49
|
|
45
50
|
Now you can get access token from access code.
|
46
51
|
|
47
52
|
```ruby
|
48
|
-
oauth.get_user_access_token
|
53
|
+
oauth.get_user_access_token(access_code)
|
49
54
|
```
|
50
55
|
|
51
56
|
On oauth_callback_url facebook will send token in params.
|
@@ -57,7 +62,7 @@ Use Fobos::GraphAPI::Users for working with user's data and Fobos::GraphAPI::Pag
|
|
57
62
|
|
58
63
|
## Contributing
|
59
64
|
|
60
|
-
1. Fork it ( https://github.com/
|
65
|
+
1. Fork it ( https://github.com/mxgoncharov/fobos/fork )
|
61
66
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
62
67
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
63
68
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/fobos.gemspec
CHANGED
@@ -39,8 +39,8 @@ module Fobos
|
|
39
39
|
#
|
40
40
|
# <b>Options</b> you can see here https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow/v2.1#login
|
41
41
|
def get_user_access_code_url(oauth_callback_url = @oauth_callback_url, options = {})
|
42
|
-
options_part =
|
43
|
-
options_part =
|
42
|
+
options_part = String.new
|
43
|
+
options_part = Options.map_options_to_params(options) unless options.empty?
|
44
44
|
|
45
45
|
query = "/dialog/oauth?client_id=#{@app_id}&redirect_uri=#{oauth_callback_url}#{options_part}"
|
46
46
|
|
@@ -33,8 +33,8 @@ module Fobos
|
|
33
33
|
#
|
34
34
|
# If you want publish something from Page you need call it with <b>PAGE_ACCESS_TOKEN</b>. You can get it from list of user's account returned by Fobos::GraphAPI::Pages.get_accounts.
|
35
35
|
def post_to_page(page_id, page_access_token, options = {})
|
36
|
-
options_part =
|
37
|
-
options_part =
|
36
|
+
options_part = String.new
|
37
|
+
options_part = Options.map_options_to_params(options) unless options.empty?
|
38
38
|
|
39
39
|
query = GRAPH_URI.to_s + "/#{page_id}" + "/feed?#{options_part}&access_token=#{page_access_token}"
|
40
40
|
|
@@ -49,10 +49,10 @@ module Fobos
|
|
49
49
|
#
|
50
50
|
# Use access_token from Fobos::GraphAPI::Pages.new
|
51
51
|
def get_feed(page_id, options = {})
|
52
|
-
|
53
|
-
options_part =
|
52
|
+
options.add_access_token_to_options(@access_token)
|
53
|
+
options_part = Options.map_options_to_params(options)
|
54
54
|
|
55
|
-
query = GRAPH_URI.to_s + "/#{page_id}" + "/feed?#{options_part}
|
55
|
+
query = GRAPH_URI.to_s + "/#{page_id}" + "/feed?#{options_part}"
|
56
56
|
|
57
57
|
self.class.get(query)
|
58
58
|
end
|
@@ -5,7 +5,6 @@ module Fobos
|
|
5
5
|
module GraphAPI
|
6
6
|
class Users
|
7
7
|
include HTTParty
|
8
|
-
|
9
8
|
# You can get access token with Fobos::GraphAPI::Oauth.
|
10
9
|
attr_accessor :access_token
|
11
10
|
|
@@ -19,34 +18,42 @@ module Fobos
|
|
19
18
|
@access_token = access_token
|
20
19
|
end
|
21
20
|
|
22
|
-
#
|
21
|
+
# Generate link for getting user's data with options.
|
23
22
|
# Options must be a hash. You can provide value as String or Array.
|
24
23
|
#
|
25
|
-
# E.g. Fobos::GraphAPI::Users.new(access_token).
|
26
|
-
def
|
27
|
-
|
28
|
-
options_part =
|
24
|
+
# E.g. Fobos::GraphAPI::Users.new(access_token).get_request_url(fields: 'id') will return "https://graph.facebook.com/v2.1/me?fields=id&access_token=some_token"
|
25
|
+
def get_request_url(options = {})
|
26
|
+
options.add_access_token_to_options(@access_token)
|
27
|
+
options_part = Options.map_options_to_params(options)
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
self.class.get(query)
|
29
|
+
GRAPH_URI.to_s + '/v2.1' '/me?' + options_part
|
33
30
|
end
|
34
31
|
|
35
|
-
|
32
|
+
|
33
|
+
# Generate link for post request (publishing) for user.
|
36
34
|
# Options must be a hash. You can provide value as String or Array.
|
37
35
|
#
|
38
|
-
# E.g. Fobos::GraphAPI::Users.new(access_token).post_request(message: 'This is test message') will
|
39
|
-
def
|
40
|
-
|
41
|
-
options_part =
|
36
|
+
# E.g. Fobos::GraphAPI::Users.new(access_token).post_request(message: 'This is test message') will return "https://graph.facebook.com/v2.1/me/feed?message=This is test message&access_token=some_token"
|
37
|
+
def post_request_url(options = {})
|
38
|
+
options.add_access_token_to_options(@access_token)
|
39
|
+
options_part = Options.map_options_to_params(options)
|
42
40
|
|
43
|
-
query = GRAPH_URI.to_s + '/v2.1' '/me/feed?' + options_part
|
41
|
+
query = GRAPH_URI.to_s + '/v2.1' '/me/feed?' + options_part
|
42
|
+
end
|
44
43
|
|
45
|
-
encoded_url = URI.encode(query)
|
46
44
|
|
47
|
-
|
45
|
+
|
46
|
+
# Provides call of get_request_url
|
47
|
+
def get_request(options = {})
|
48
|
+
self.class.get(get_request_url(options))
|
48
49
|
end
|
49
50
|
|
51
|
+
# Provides call of post_request_url
|
52
|
+
def post_request(options = {})
|
53
|
+
encoded_url = URI.encode(post_request_url(options))
|
54
|
+
|
55
|
+
self.class.post(URI.parse(encoded_url))
|
56
|
+
end
|
50
57
|
end
|
51
58
|
end
|
52
59
|
end
|
data/lib/fobos/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fobos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Goncharov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -60,6 +60,7 @@ extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
63
64
|
- Gemfile
|
64
65
|
- LICENSE.txt
|
65
66
|
- README.md
|
@@ -67,7 +68,9 @@ files:
|
|
67
68
|
- fobos.gemspec
|
68
69
|
- lib/fobos.rb
|
69
70
|
- lib/fobos/graph_api/graph_api.rb
|
71
|
+
- lib/fobos/graph_api/hash.rb
|
70
72
|
- lib/fobos/graph_api/o_auth.rb
|
73
|
+
- lib/fobos/graph_api/options.rb
|
71
74
|
- lib/fobos/graph_api/pages.rb
|
72
75
|
- lib/fobos/graph_api/users.rb
|
73
76
|
- lib/fobos/version.rb
|