graph-api 0.9.9 → 1.0.0
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 +13 -0
- data/lib/graph_api/version.rb +1 -1
- data/readme.md +1 -0
- data/spec/graph_api_spec.rb +10 -2
- metadata +1 -1
data/Gemfile.lock
CHANGED
data/lib/graph_api.rb
CHANGED
|
@@ -40,6 +40,13 @@ class GraphAPI
|
|
|
40
40
|
# @callback_url = nil
|
|
41
41
|
attr_accessor :callback_url
|
|
42
42
|
|
|
43
|
+
# Public: Non-reqired setting used for Facebook call back URL when logging out of a Facebook application.
|
|
44
|
+
#
|
|
45
|
+
# Example
|
|
46
|
+
#
|
|
47
|
+
# @logout_url = nil
|
|
48
|
+
attr_accessor :logout_url
|
|
49
|
+
|
|
43
50
|
# Public: Required setting used for setting Facebook application requirements.
|
|
44
51
|
#
|
|
45
52
|
# Example
|
|
@@ -141,6 +148,12 @@ class GraphAPI
|
|
|
141
148
|
self.picture['data']['url']
|
|
142
149
|
end
|
|
143
150
|
|
|
151
|
+
# Public: Returns a URL designed to log a user out of Facebook and redirect
|
|
152
|
+
# them back to your Facebook application.
|
|
153
|
+
def logout_url
|
|
154
|
+
"https://www.facebook.com/logout.php?next=#{self.class.logout_url}&access_token=#@access_token"
|
|
155
|
+
end
|
|
156
|
+
|
|
144
157
|
# Public: Meta methods for each of the user fields declared.
|
|
145
158
|
#
|
|
146
159
|
# Example:
|
data/lib/graph_api/version.rb
CHANGED
data/readme.md
CHANGED
|
@@ -18,6 +18,7 @@ You will have to configure the gem before using it. Here is an example setup.
|
|
|
18
18
|
app_secret '124ca2a483f12723cafa7a5da33a3492' # The Facebook Application Secret
|
|
19
19
|
client_id '234513432316919' # The Facebook Application Id
|
|
20
20
|
callback_url 'http://example.com/facebook_callback/' # URI for receiving the Facebook code param
|
|
21
|
+
logout_url 'http://example.com/logout/' # URI to redirect to when logging out
|
|
21
22
|
access_scope [:offline_access, :email, :user_photos] # The Facebook application requirements
|
|
22
23
|
user_fields [:id, :picture, :name, :gender, :email] # The user fields pulled for
|
|
23
24
|
end
|
data/spec/graph_api_spec.rb
CHANGED
|
@@ -11,12 +11,14 @@ describe GraphAPI do
|
|
|
11
11
|
app_secret 'APP_SECRET'
|
|
12
12
|
client_id 'CLIENT_ID'
|
|
13
13
|
callback_url 'CALLBACK_URL'
|
|
14
|
+
logout_url 'LOGOUT_URL'
|
|
14
15
|
access_scope 'ACCESS_SCOPE'
|
|
15
16
|
user_fields 'USER_FIELDS'
|
|
16
17
|
end
|
|
17
18
|
GraphAPI.app_secret.should == 'APP_SECRET'
|
|
18
19
|
GraphAPI.client_id.should == 'CLIENT_ID'
|
|
19
20
|
GraphAPI.callback_url.should == 'CALLBACK_URL'
|
|
21
|
+
GraphAPI.logout_url.should == 'LOGOUT_URL'
|
|
20
22
|
GraphAPI.access_scope.should == 'ACCESS_SCOPE'
|
|
21
23
|
GraphAPI.user_fields.should == 'USER_FIELDS'
|
|
22
24
|
end
|
|
@@ -73,12 +75,13 @@ describe GraphAPI do
|
|
|
73
75
|
end
|
|
74
76
|
|
|
75
77
|
context 'Instance' do
|
|
78
|
+
let(:fg_user) { GraphAPI.new('ACCESS_TOKEN') }
|
|
79
|
+
|
|
76
80
|
describe '#photo' do
|
|
77
81
|
it 'should return a photo URI' do
|
|
78
82
|
albums_data = {'data' => [{'type' => 'profile', 'cover_photo' => 'PHOTO_ID'}]}
|
|
79
83
|
GraphAPI.should_receive(:request).with('/me/albums?fields=id,cover_photo,type', 'ACCESS_TOKEN').and_return(albums_data)
|
|
80
84
|
GraphAPI.should_receive(:request).with('/PHOTO_ID/?fields=source', 'ACCESS_TOKEN').and_return({'source' => 'PHOTO_URI'})
|
|
81
|
-
fg_user = GraphAPI.new('ACCESS_TOKEN')
|
|
82
85
|
fg_user.photo.should == 'PHOTO_URI'
|
|
83
86
|
end
|
|
84
87
|
end
|
|
@@ -87,9 +90,14 @@ describe GraphAPI do
|
|
|
87
90
|
it 'should return a photo URI' do
|
|
88
91
|
GraphAPI.user_fields = []
|
|
89
92
|
GraphAPI.should_receive(:request).with('/me?fields=picture', 'ACCESS_TOKEN').and_return({'picture' => {'data' => {'url' => 'PHOTO_URI'}}})
|
|
90
|
-
fg_user = GraphAPI.new('ACCESS_TOKEN')
|
|
91
93
|
fg_user.thumbnail.should == 'PHOTO_URI'
|
|
92
94
|
end
|
|
93
95
|
end
|
|
96
|
+
|
|
97
|
+
describe '#logout_url' do
|
|
98
|
+
it 'should return the correct logout URL' do
|
|
99
|
+
fg_user.logout_url.should == 'https://www.facebook.com/logout.php?next=LOGOUT_URL&access_token=ACCESS_TOKEN'
|
|
100
|
+
end
|
|
101
|
+
end
|
|
94
102
|
end
|
|
95
103
|
end
|