facebooker2 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -156,10 +156,22 @@ module Facebooker2
156
156
  #default values for the cookie
157
157
  value = 'deleted'
158
158
  expires = Time.now.utc - 3600 unless expires != nil
159
+
160
+ # If the expires value is set to some large value in the future, then the 'offline access' permission has been
161
+ # granted. In the Facebook JS SDK, this causes a value of 0 to be set for the expires parameter. This value
162
+ # needs to be correct otherwise the request signing fails, so if the expires parameter retrieved from the graph
163
+ # api is more than a year in the future, then we set expires to 0 to match the JS SDK.
164
+ expires = 0 if expires > Time.now + 1.year
159
165
 
160
166
  if access_token
167
+ # Retrieve the existing cookie data
161
168
  data = fb_cookie_hash || {}
162
- data.merge!('access_token' => access_token, 'uid' => uid, 'sig' => sig, "expires" => expires.to_i.to_s)
169
+ # Remove the deleted value if this has previously been set, as we don't want to include it as part of the
170
+ # request signing parameters
171
+ data.delete('deleted') if data.key?('deleted')
172
+ # Keep existing cookie data that could have been set by FB JS SDK
173
+ data.merge!('access_token' => access_token, 'uid' => uid, 'sig' => sig, 'expires' => expires.to_i.to_s)
174
+ # Create string to store in cookie
163
175
  value = '"'
164
176
  data.each do |k,v|
165
177
  value += "#{k.to_s}=#{v.to_s}&"
@@ -169,7 +181,7 @@ module Facebooker2
169
181
  end
170
182
 
171
183
  # if an existing cookie is not set, we dont need to delete it
172
- if (value == 'deleted' && cookies[fb_cookie_name] == "" )
184
+ if (value == 'deleted' && (!fb_cookie? || fb_cookie == "" ))
173
185
  return;
174
186
  end
175
187
 
@@ -16,6 +16,7 @@ module Facebooker2
16
16
  cookie = opts[:cookie]
17
17
  status = opts[:status]
18
18
  xfbml = opts[:xfbml]
19
+ channel_url = opts[:channel_url]
19
20
  extra_js = capture(&proc) if block_given?
20
21
  js = <<-JAVASCRIPT
21
22
  <script>
@@ -24,6 +25,7 @@ module Facebooker2
24
25
  appId : '#{app_id}',
25
26
  status : #{status}, // check login status
26
27
  cookie : #{cookie}, // enable cookies to allow the server to access the session
28
+ #{"channelUrl : '#{channel_url}', // add channelURL to avoid IE redirect problems" unless channel_url.blank?}
27
29
  xfbml : #{xfbml} // parse XFBML
28
30
  });
29
31
  #{extra_js}
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facebooker2
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 8
10
- version: 0.0.8
9
+ - 9
10
+ version: 0.0.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Mike Mangino
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-10 00:00:00 -05:00
18
+ date: 2011-03-10 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency