graph-api 0.9.8 → 0.9.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -1
- data/lib/graph_api.rb +12 -5
- data/lib/graph_api/version.rb +1 -1
- data/readme.md +8 -6
- data/spec/graph_api_spec.rb +7 -6
- metadata +1 -1
data/Gemfile.lock
CHANGED
data/lib/graph_api.rb
CHANGED
@@ -12,7 +12,7 @@ require 'graph_api/version'
|
|
12
12
|
# end
|
13
13
|
#
|
14
14
|
# get '/facebook_callback' do
|
15
|
-
# @facebook_user = GraphAPI.new(params[:code])
|
15
|
+
# @facebook_user = GraphAPI.new(false, params[:code])
|
16
16
|
# session[:auth_token] = @facebook_user.auth_token
|
17
17
|
# render :signed_in
|
18
18
|
# end
|
@@ -59,11 +59,18 @@ class GraphAPI
|
|
59
59
|
#
|
60
60
|
# Example:
|
61
61
|
#
|
62
|
-
# GraphAPI.config
|
63
|
-
#
|
62
|
+
# GraphAPI.config do
|
63
|
+
# app_secret '124ca2a483f12723cafa7a5da33a3492'
|
64
|
+
# client_id '234513432316919'
|
65
|
+
# end
|
64
66
|
#
|
65
|
-
def self.config(
|
66
|
-
|
67
|
+
def self.config(&block)
|
68
|
+
config = Class.new do
|
69
|
+
def self.method_missing(setting, value)
|
70
|
+
@settings ||= []
|
71
|
+
@settings << [setting, value]
|
72
|
+
end
|
73
|
+
end.class_eval(&block).each do |setting, value|
|
67
74
|
self.send("#{setting}=", value)
|
68
75
|
end
|
69
76
|
end
|
data/lib/graph_api/version.rb
CHANGED
data/readme.md
CHANGED
@@ -14,11 +14,13 @@ Here is how to use it.
|
|
14
14
|
|
15
15
|
You will have to configure the gem before using it. Here is an example setup.
|
16
16
|
|
17
|
-
GraphAPI.config
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
GraphAPI.config do
|
18
|
+
app_secret '124ca2a483f12723cafa7a5da33a3492' # The Facebook Application Secret
|
19
|
+
client_id '234513432316919' # The Facebook Application Id
|
20
|
+
callback_url 'http://example.com/facebook_callback/' # URI for receiving the Facebook code param
|
21
|
+
access_scope [:offline_access, :email, :user_photos] # The Facebook application requirements
|
22
|
+
user_fields [:id, :picture, :name, :gender, :email] # The user fields pulled for
|
23
|
+
end
|
22
24
|
|
23
25
|
Visit https://developers.facebook.com/apps to register your Facebook application
|
24
26
|
or checkout https://developers.facebook.com/docs/reference/api/user/ for a list
|
@@ -34,7 +36,7 @@ user fields in your application. Here is basic example using Sinatra.
|
|
34
36
|
end
|
35
37
|
|
36
38
|
get '/facebook_callback' do
|
37
|
-
@facebook_user = GraphAPI.new(params[:code])
|
39
|
+
@facebook_user = GraphAPI.new(false, params[:code])
|
38
40
|
session[:auth_token] = @facebook_user.auth_token
|
39
41
|
render :signed_in
|
40
42
|
end
|
data/spec/graph_api_spec.rb
CHANGED
@@ -7,12 +7,13 @@ describe GraphAPI do
|
|
7
7
|
|
8
8
|
describe '#config' do
|
9
9
|
it 'should configuration constants to be set' do
|
10
|
-
GraphAPI.config
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
GraphAPI.config do
|
11
|
+
app_secret 'APP_SECRET'
|
12
|
+
client_id 'CLIENT_ID'
|
13
|
+
callback_url 'CALLBACK_URL'
|
14
|
+
access_scope 'ACCESS_SCOPE'
|
15
|
+
user_fields 'USER_FIELDS'
|
16
|
+
end
|
16
17
|
GraphAPI.app_secret.should == 'APP_SECRET'
|
17
18
|
GraphAPI.client_id.should == 'CLIENT_ID'
|
18
19
|
GraphAPI.callback_url.should == 'CALLBACK_URL'
|