rfacebook 0.6.3 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/facebook_rails_controller_extensions.rb +22 -9
- data/lib/facebook_session.rb +13 -13
- metadata +2 -2
@@ -5,24 +5,24 @@ module RFacebook
|
|
5
5
|
module RailsControllerExtensions
|
6
6
|
|
7
7
|
|
8
|
-
# SECTION:
|
8
|
+
# SECTION: StandardErrors
|
9
9
|
|
10
|
-
class
|
11
|
-
class
|
12
|
-
class
|
10
|
+
class APIKeyNeededStandardError < StandardError; end
|
11
|
+
class APISecretNeededStandardError < StandardError; end
|
12
|
+
class APIFinisherNeededStandardError < StandardError; end
|
13
13
|
|
14
14
|
# SECTION: Template Methods (must be implemented by concrete subclass)
|
15
15
|
|
16
16
|
def facebook_api_key
|
17
|
-
raise
|
17
|
+
raise APIKeyNeededStandardError
|
18
18
|
end
|
19
19
|
|
20
20
|
def facebook_api_secret
|
21
|
-
raise
|
21
|
+
raise APISecretNeededStandardError
|
22
22
|
end
|
23
23
|
|
24
24
|
def finish_facebook_login
|
25
|
-
raise
|
25
|
+
raise APIFinisherNeededStandardError
|
26
26
|
end
|
27
27
|
|
28
28
|
|
@@ -31,7 +31,7 @@ module RFacebook
|
|
31
31
|
|
32
32
|
def fbparams
|
33
33
|
|
34
|
-
|
34
|
+
params = (params || {}).dup
|
35
35
|
|
36
36
|
# try to get fbparams from the params hash
|
37
37
|
if (@fbparams.length <= 0)
|
@@ -81,7 +81,9 @@ module RFacebook
|
|
81
81
|
|
82
82
|
def facebook_redirect_to(url)
|
83
83
|
if in_facebook_canvas?
|
84
|
-
render :text => "<fb:redirect url=\"#{url}\" />"
|
84
|
+
render :text => "<fb:redirect url=\"#{url}\" />"
|
85
|
+
elsif url =~ /^https?:\/\/([^\/]*\.)?facebook\.com(:\d+)?/i
|
86
|
+
render :text => "<script type=\"text/javascript\">\ntop.location.href = \"#{url}\";\n</script>";
|
85
87
|
else
|
86
88
|
redirect_to url
|
87
89
|
end
|
@@ -105,9 +107,12 @@ module RFacebook
|
|
105
107
|
|
106
108
|
# template method call upon success
|
107
109
|
if session[:rfacebook_fbsession].is_valid?
|
110
|
+
RAILS_DEFAULT_LOGGER.debug "** rfacebook: Login was successful, calling finish_facebook_login"
|
108
111
|
finish_facebook_login
|
109
112
|
end
|
110
113
|
|
114
|
+
else
|
115
|
+
RAILS_DEFAULT_LOGGER.debug "** rfacebook: Didn't activate session from handle_facebook_login"
|
111
116
|
end
|
112
117
|
|
113
118
|
end
|
@@ -118,15 +123,23 @@ module RFacebook
|
|
118
123
|
handle_facebook_login
|
119
124
|
|
120
125
|
if !performed?
|
126
|
+
|
127
|
+
RAILS_DEFAULT_LOGGER.debug "** rfacebook: Rendering has not been performed"
|
128
|
+
|
121
129
|
# try to get the session
|
122
130
|
sess = fbsession
|
123
131
|
|
124
132
|
# handle invalid sessions by forcing the user to log in
|
125
133
|
if !sess.is_valid?
|
134
|
+
|
135
|
+
RAILS_DEFAULT_LOGGER.debug "** rfacebook: Session is not valid"
|
136
|
+
|
126
137
|
if in_facebook_canvas?
|
138
|
+
RAILS_DEFAULT_LOGGER.debug "** rfacebook: Rendering canvas redirect"
|
127
139
|
render :text => "<fb:redirect url=\"#{sess.get_login_url(:canvas=>true)}\" />"
|
128
140
|
return false
|
129
141
|
else
|
142
|
+
RAILS_DEFAULT_LOGGER.debug "** rfacebook: Redirecting to login"
|
130
143
|
redirect_to sess.get_login_url
|
131
144
|
return false
|
132
145
|
end
|
data/lib/facebook_session.rb
CHANGED
@@ -53,11 +53,11 @@ class FacebookSession
|
|
53
53
|
attr_reader :last_call_was_successful, :last_error
|
54
54
|
attr_writer :suppress_exceptions
|
55
55
|
|
56
|
-
# SECTION:
|
56
|
+
# SECTION: StandardErrors
|
57
57
|
|
58
|
-
class
|
59
|
-
class
|
60
|
-
class
|
58
|
+
class RemoteStandardError < StandardError; end
|
59
|
+
class ExpiredSessionStandardError < StandardError; end
|
60
|
+
class NotActivatedStandardError < StandardError; end
|
61
61
|
|
62
62
|
# SECTION: Public Methods
|
63
63
|
|
@@ -95,19 +95,19 @@ class FacebookSession
|
|
95
95
|
# SECTION: Public Abstract Interface
|
96
96
|
|
97
97
|
def is_valid?
|
98
|
-
raise
|
98
|
+
raise StandardError
|
99
99
|
end
|
100
100
|
|
101
101
|
def session_key
|
102
|
-
raise
|
102
|
+
raise StandardError
|
103
103
|
end
|
104
104
|
|
105
105
|
def session_user_id
|
106
|
-
raise
|
106
|
+
raise StandardError
|
107
107
|
end
|
108
108
|
|
109
109
|
def session_expires
|
110
|
-
raise
|
110
|
+
raise StandardError
|
111
111
|
end
|
112
112
|
|
113
113
|
def session_uid # deprecated
|
@@ -118,11 +118,11 @@ class FacebookSession
|
|
118
118
|
protected
|
119
119
|
|
120
120
|
def get_secret(params)
|
121
|
-
raise
|
121
|
+
raise StandardError
|
122
122
|
end
|
123
123
|
|
124
124
|
def is_activated?
|
125
|
-
raise
|
125
|
+
raise StandardError
|
126
126
|
end
|
127
127
|
|
128
128
|
# SECTION: Protected Concrete Interface
|
@@ -150,7 +150,7 @@ class FacebookSession
|
|
150
150
|
|
151
151
|
# ensure that this object has been activated somehow
|
152
152
|
if (!method.include?("auth") and !is_activated?)
|
153
|
-
raise
|
153
|
+
raise NotActivatedStandardError, "You must activate the session before using it."
|
154
154
|
end
|
155
155
|
|
156
156
|
# set up params hash
|
@@ -189,11 +189,11 @@ class FacebookSession
|
|
189
189
|
# check to see if this error was an expired session error
|
190
190
|
if code.to_i == 102
|
191
191
|
@session_expired = true
|
192
|
-
raise
|
192
|
+
raise ExpiredSessionStandardError, @last_error unless @suppress_exceptions == true
|
193
193
|
end
|
194
194
|
|
195
195
|
# otherwise, just throw a generic expired session
|
196
|
-
raise
|
196
|
+
raise RemoteStandardError, @last_error unless @suppress_exceptions == true
|
197
197
|
|
198
198
|
return nil
|
199
199
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rfacebook
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.6.
|
7
|
-
date: 2007-07-
|
6
|
+
version: 0.6.4
|
7
|
+
date: 2007-07-15 00:00:00 -07:00
|
8
8
|
summary: A Ruby interface to the Facebook API v1.0+. Supports the new features from F8.
|
9
9
|
require_paths:
|
10
10
|
- lib
|