facebooker 1.0.55 → 1.0.56
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/facebooker.gemspec +2 -2
- data/lib/facebooker/models/user.rb +79 -70
- data/lib/facebooker/rails/helpers.rb +8 -0
- data/lib/facebooker/rails/helpers/fb_connect.rb +7 -0
- data/lib/facebooker/rails/test_helpers.rb +10 -10
- data/lib/facebooker/session.rb +3 -1
- data/lib/facebooker/version.rb +1 -1
- data/test/facebooker/application_test.rb +1 -1
- data/test/facebooker/models/user_test.rb +21 -10
- data/test/facebooker/rails_integration_test.rb +4 -0
- metadata +2 -2
data/facebooker.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{facebooker}
|
5
|
-
s.version = "1.0.
|
5
|
+
s.version = "1.0.56"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Chad Fowler", "Patrick Ewing", "Mike Mangino", "Shane Vitarana", "Corey Innis", "Mike Mangino"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-12-04}
|
10
10
|
s.description = %q{Facebooker is a Ruby wrapper over the Facebook[http://facebook.com] {REST API}[http://wiki.developers.facebook.com/index.php/API]. Its goals are:
|
11
11
|
|
12
12
|
* Idiomatic Ruby
|
@@ -3,7 +3,7 @@ require 'facebooker/models/affiliation'
|
|
3
3
|
require 'facebooker/models/work_info'
|
4
4
|
require 'facebooker/models/family_relative_info'
|
5
5
|
module Facebooker
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# Holds attributes and behavior for a Facebook User
|
8
8
|
class User
|
9
9
|
include Model
|
@@ -76,8 +76,8 @@ module Facebooker
|
|
76
76
|
result = @session.post('facebook.events.rsvp', options.merge(:eid => eid, :rsvp_status => rsvp_status))
|
77
77
|
result == '1' ? true : false
|
78
78
|
end
|
79
|
-
|
80
|
-
#
|
79
|
+
|
80
|
+
#
|
81
81
|
# Set the list of friends, given an array of User objects. If the list has been retrieved previously, will not set
|
82
82
|
def friends=(list_of_friends,flid=nil)
|
83
83
|
@friends_hash ||= {}
|
@@ -87,7 +87,7 @@ module Facebooker
|
|
87
87
|
|
88
88
|
@friends_hash[cache_key] ||= list_of_friends
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
def cast_to_friend_list_id(flid)
|
92
92
|
case flid
|
93
93
|
when String
|
@@ -130,6 +130,9 @@ module Facebooker
|
|
130
130
|
#
|
131
131
|
# +target+ can be the current user or some other user.
|
132
132
|
#
|
133
|
+
# To publish to a Page on the Page's behave, specify the page id as
|
134
|
+
# :uid and set :post_as_page to 'true', use the current user as target
|
135
|
+
#
|
133
136
|
# Example:
|
134
137
|
# # Publish a message to my own wall:
|
135
138
|
# me.publish_to(me, :message => 'hello world')
|
@@ -142,12 +145,12 @@ module Facebooker
|
|
142
145
|
def publish_to(target, options = {})
|
143
146
|
@session.post('facebook.stream.publish', prepare_publish_to_options(target, options), false)
|
144
147
|
end
|
145
|
-
|
148
|
+
|
146
149
|
# Prepares options for the stream.publish
|
147
150
|
def prepare_publish_to_options(target, options)
|
148
151
|
opts = {:uid => self.id,
|
149
152
|
:target_id => target.id,
|
150
|
-
:message => options[:message]}
|
153
|
+
:message => options[:message]}
|
151
154
|
|
152
155
|
if(attachment = options[:attachment] && Facebooker.json_encode(options[:attachment]))
|
153
156
|
opts[:attachment] = attachment
|
@@ -155,9 +158,15 @@ module Facebooker
|
|
155
158
|
if (links = options[:action_links] && Facebooker.json_encode(options[:action_links]))
|
156
159
|
opts[:action_links] = links
|
157
160
|
end
|
161
|
+
unless options[:uid].nil?
|
162
|
+
opts[:uid] = options[:uid]
|
163
|
+
end
|
164
|
+
if options[:post_as_page]
|
165
|
+
opts.delete(:target_id)
|
166
|
+
end
|
158
167
|
opts
|
159
168
|
end
|
160
|
-
|
169
|
+
|
161
170
|
###
|
162
171
|
# Publish a comment on a post
|
163
172
|
#
|
@@ -168,7 +177,7 @@ module Facebooker
|
|
168
177
|
def comment_on(post_id, comment)
|
169
178
|
@session.post('facebook.stream.addComment', {:post_id=>post_id, :comment=>comment})
|
170
179
|
end
|
171
|
-
|
180
|
+
|
172
181
|
|
173
182
|
def friend_lists
|
174
183
|
@friend_lists ||= @session.post('facebook.friends.getLists').map do |hash|
|
@@ -182,11 +191,11 @@ module Facebooker
|
|
182
191
|
# Subsequent calls will be retrieved from memory.
|
183
192
|
# Optional: list of fields to retrieve as symbols
|
184
193
|
def friends!(*fields)
|
185
|
-
@friends ||= session.post('facebook.users.getInfo', :fields => collect(fields), :uids => friends.map{|f| f.id}.join(',')).map do |hash|
|
194
|
+
@friends ||= session.post('facebook.users.getInfo', :fields => collect(fields), :uids => friends.map{|f| f.id}.join(',')).map do |hash|
|
186
195
|
User.new(hash['uid'], session, hash)
|
187
196
|
end
|
188
197
|
end
|
189
|
-
|
198
|
+
|
190
199
|
###
|
191
200
|
# Retrieve profile data for logged in user
|
192
201
|
# Optional: list of fields to retrieve as symbols
|
@@ -195,11 +204,11 @@ module Facebooker
|
|
195
204
|
populate_from_hash!(response.first)
|
196
205
|
end
|
197
206
|
end
|
198
|
-
|
207
|
+
|
199
208
|
def friends_with?(user_or_id)
|
200
|
-
friends.map{|f| f.to_i}.include?(user_or_id.to_i)
|
209
|
+
friends.map{|f| f.to_i}.include?(user_or_id.to_i)
|
201
210
|
end
|
202
|
-
|
211
|
+
|
203
212
|
def friends_with_this_app
|
204
213
|
@friends_with_this_app ||= friend_ids_with_this_app.map do |uid|
|
205
214
|
User.new(uid, session)
|
@@ -209,7 +218,7 @@ module Facebooker
|
|
209
218
|
def friend_ids_with_this_app
|
210
219
|
@friend_ids_with_this_app ||= session.post('facebook.friends.getAppUsers')
|
211
220
|
end
|
212
|
-
|
221
|
+
|
213
222
|
def groups(gids = [])
|
214
223
|
args = gids.empty? ? {} : {:gids => gids}
|
215
224
|
@groups ||= session.post('facebook.groups.get', args).map do |hash|
|
@@ -218,23 +227,23 @@ module Facebooker
|
|
218
227
|
group
|
219
228
|
end
|
220
229
|
end
|
221
|
-
|
230
|
+
|
222
231
|
def notifications
|
223
232
|
@notifications ||= Notifications.from_hash(session.post('facebook.notifications.get'))
|
224
233
|
end
|
225
|
-
|
234
|
+
|
226
235
|
def publish_story(story)
|
227
236
|
publish(story)
|
228
237
|
end
|
229
|
-
|
238
|
+
|
230
239
|
def publish_action(action)
|
231
240
|
publish(action)
|
232
241
|
end
|
233
|
-
|
242
|
+
|
234
243
|
def publish_templatized_action(action)
|
235
244
|
publish(action)
|
236
245
|
end
|
237
|
-
|
246
|
+
|
238
247
|
def albums
|
239
248
|
@albums ||= session.post('facebook.photos.getAlbums', :uid => self.id) do |response|
|
240
249
|
response.map do |hash|
|
@@ -242,15 +251,15 @@ module Facebooker
|
|
242
251
|
end
|
243
252
|
end
|
244
253
|
end
|
245
|
-
|
254
|
+
|
246
255
|
def create_album(params)
|
247
256
|
@album = session.post('facebook.photos.createAlbum', params) {|response| Album.from_hash(response)}
|
248
257
|
end
|
249
|
-
|
258
|
+
|
250
259
|
def profile_photos
|
251
260
|
session.get_photos(nil, nil, profile_pic_album_id)
|
252
261
|
end
|
253
|
-
|
262
|
+
|
254
263
|
# Upload a photo to the user's profile.
|
255
264
|
#
|
256
265
|
# In your view, create a multipart form that posts directly to your application (not through canvas):
|
@@ -260,8 +269,8 @@ module Facebooker
|
|
260
269
|
# Caption: <%= text_area_tag 'caption' %>
|
261
270
|
# <%= submit_tag 'Upload Photo', :class => 'inputsubmit' %>
|
262
271
|
# <% end %>
|
263
|
-
#
|
264
|
-
# And in your controller:
|
272
|
+
#
|
273
|
+
# And in your controller:
|
265
274
|
#
|
266
275
|
# class PhotosController < ApplicationController
|
267
276
|
# def create
|
@@ -270,7 +279,7 @@ module Facebooker
|
|
270
279
|
# params[:photo].content_type,
|
271
280
|
# params[:photo].read
|
272
281
|
# )
|
273
|
-
#
|
282
|
+
#
|
274
283
|
# @photo = facebook_session.user.upload_photo(file, :caption => params[:caption])
|
275
284
|
# redirect_to photos_url(:canvas => true)
|
276
285
|
# end
|
@@ -281,7 +290,7 @@ module Facebooker
|
|
281
290
|
Photo.from_hash(session.post_file('facebook.photos.upload',
|
282
291
|
options.merge(nil => multipart_post_file)))
|
283
292
|
end
|
284
|
-
|
293
|
+
|
285
294
|
# Upload a video to the user's profile.
|
286
295
|
#
|
287
296
|
# In your view, create a multipart form that posts directly to your application (not through canvas):
|
@@ -292,8 +301,8 @@ module Facebooker
|
|
292
301
|
# Description: <%= text_area_tag 'description' %>
|
293
302
|
# <%= submit_tag 'Upload Video', :class => 'inputsubmit' %>
|
294
303
|
# <% end %>
|
295
|
-
#
|
296
|
-
# And in your controller:
|
304
|
+
#
|
305
|
+
# And in your controller:
|
297
306
|
#
|
298
307
|
# class VideosController < ApplicationController
|
299
308
|
# def create
|
@@ -302,7 +311,7 @@ module Facebooker
|
|
302
311
|
# params[:photo].content_type,
|
303
312
|
# params[:photo].read
|
304
313
|
# )
|
305
|
-
#
|
314
|
+
#
|
306
315
|
# @video = facebook_session.user.upload_video(file, :description => params[:description])
|
307
316
|
# redirect_to videos_url(:canvas => true)
|
308
317
|
# end
|
@@ -313,11 +322,11 @@ module Facebooker
|
|
313
322
|
Video.from_hash(session.post_file('facebook.video.upload',
|
314
323
|
options.merge(nil => multipart_post_file, :base => Facebooker.video_server_base)))
|
315
324
|
end
|
316
|
-
|
325
|
+
|
317
326
|
def profile_fbml
|
318
|
-
session.post('facebook.profile.getFBML', :uid => id)
|
319
|
-
end
|
320
|
-
|
327
|
+
session.post('facebook.profile.getFBML', :uid => id)
|
328
|
+
end
|
329
|
+
|
321
330
|
##
|
322
331
|
# Set the profile FBML for this user
|
323
332
|
#
|
@@ -325,21 +334,21 @@ module Facebooker
|
|
325
334
|
def profile_fbml=(markup)
|
326
335
|
set_profile_fbml(markup, nil, nil, nil)
|
327
336
|
end
|
328
|
-
|
337
|
+
|
329
338
|
##
|
330
339
|
# Set the mobile profile FBML
|
331
340
|
def mobile_fbml=(markup)
|
332
341
|
set_profile_fbml(nil, markup, nil,nil)
|
333
342
|
end
|
334
|
-
|
343
|
+
|
335
344
|
def profile_action=(markup)
|
336
345
|
set_profile_fbml(nil, nil, markup,nil)
|
337
346
|
end
|
338
|
-
|
347
|
+
|
339
348
|
def profile_main=(markup)
|
340
349
|
set_profile_fbml(nil,nil,nil,markup)
|
341
350
|
end
|
342
|
-
|
351
|
+
|
343
352
|
def set_profile_fbml(profile_fbml, mobile_fbml, profile_action_fbml, profile_main = nil)
|
344
353
|
parameters = {:uid => id}
|
345
354
|
parameters[:profile] = profile_fbml if profile_fbml
|
@@ -348,21 +357,21 @@ module Facebooker
|
|
348
357
|
parameters[:profile_main] = profile_main if profile_main
|
349
358
|
session.post('facebook.profile.setFBML', parameters,false)
|
350
359
|
end
|
351
|
-
|
360
|
+
|
352
361
|
## ** NEW PROFILE DESIGN ***
|
353
362
|
# Set a info section for this user
|
354
363
|
#
|
355
364
|
# Note: using set_profile_info as I feel using user.set_info could be confused with the user.getInfo facebook method.
|
356
365
|
# Also, I feel it fits in line with user.set_profile_fbml.
|
357
366
|
def set_profile_info(title, info_fields, format = :text)
|
358
|
-
session.post('facebook.profile.setInfo', :title => title, :uid => id,
|
367
|
+
session.post('facebook.profile.setInfo', :title => title, :uid => id,
|
359
368
|
:type => format.to_s == "text" ? 1 : 5, :info_fields => info_fields.to_json)
|
360
369
|
end
|
361
|
-
|
370
|
+
|
362
371
|
def get_profile_info
|
363
372
|
session.post('facebook.profile.getInfo', :uid => id)
|
364
373
|
end
|
365
|
-
|
374
|
+
|
366
375
|
##
|
367
376
|
# This DOES NOT set the status of a user on Facebook
|
368
377
|
# Use the set_status method instead
|
@@ -374,9 +383,9 @@ module Facebooker
|
|
374
383
|
@status = Status.from_hash(message)
|
375
384
|
end
|
376
385
|
end
|
377
|
-
|
378
386
|
|
379
|
-
|
387
|
+
|
388
|
+
##
|
380
389
|
# Return +limit+ statuses from the user
|
381
390
|
def statuses( limit = 50 )
|
382
391
|
session.post('facebook.status.get', {:uid => uid, :limit => limit}).collect { |ret| Status.from_hash(ret) }
|
@@ -386,65 +395,65 @@ module Facebooker
|
|
386
395
|
# Set the status for a user
|
387
396
|
# DOES NOT prepend "is" to the message
|
388
397
|
#
|
389
|
-
# requires extended permission.
|
398
|
+
# requires extended permission.
|
390
399
|
def set_status(message)
|
391
400
|
self.status=message
|
392
401
|
session.post('facebook.users.setStatus',{:status=>message,:status_includes_verb=>1,:uid => uid}, false) do |ret|
|
393
402
|
ret
|
394
403
|
end
|
395
404
|
end
|
396
|
-
|
405
|
+
|
397
406
|
##
|
398
407
|
# Checks to see if the user has enabled the given extended permission
|
399
408
|
def has_permission?(ext_perm) # ext_perm = email, offline_access, status_update, photo_upload, create_listing, create_event, rsvp_event, sms
|
400
409
|
session.post('facebook.users.hasAppPermission', {:ext_perm=>ext_perm, :uid => uid}, false) == "1"
|
401
|
-
end
|
402
|
-
|
410
|
+
end
|
411
|
+
|
403
412
|
##
|
404
413
|
# Convenience method to check multiple permissions at once
|
405
414
|
def has_permissions?(ext_perms)
|
406
415
|
ext_perms.all?{|p| has_permission?(p)}
|
407
|
-
end
|
408
|
-
|
416
|
+
end
|
417
|
+
|
409
418
|
##
|
410
419
|
# Convenience method to send email to the current user
|
411
420
|
def send_email(subject, text=nil, fbml=nil)
|
412
421
|
session.send_email([id], subject, text, fbml)
|
413
422
|
end
|
414
|
-
|
423
|
+
|
415
424
|
##
|
416
425
|
# Convenience method to set cookie for the current user
|
417
426
|
def set_cookie(name, value, expires=nil, path=nil)
|
418
427
|
session.data.set_cookie(id, name, value, expires, path)
|
419
428
|
end
|
420
|
-
|
429
|
+
|
421
430
|
##
|
422
431
|
# Convenience method to get cookies for the current user
|
423
432
|
def get_cookies(name=nil)
|
424
433
|
session.data.get_cookies(id, name)
|
425
434
|
end
|
426
|
-
|
435
|
+
|
427
436
|
##
|
428
437
|
# Returns the user's id as an integer
|
429
438
|
def to_i
|
430
439
|
id
|
431
440
|
end
|
432
|
-
|
441
|
+
|
433
442
|
def to_s
|
434
443
|
id.to_s
|
435
444
|
end
|
436
|
-
|
445
|
+
|
437
446
|
##
|
438
447
|
# Two Facebooker::User objects should be considered equal if their Facebook ids are equal
|
439
448
|
def ==(other_user)
|
440
449
|
other_user.is_a?(User) && id == other_user.id
|
441
450
|
end
|
442
|
-
|
443
|
-
|
451
|
+
|
452
|
+
|
444
453
|
# register a user with Facebook
|
445
454
|
# users should be a hast with at least an :email field
|
446
455
|
# you can optionally provide an :account_id field as well
|
447
|
-
|
456
|
+
|
448
457
|
def self.register(users)
|
449
458
|
user_map={}
|
450
459
|
users=users.map do |h|
|
@@ -487,14 +496,14 @@ module Facebooker
|
|
487
496
|
raise e
|
488
497
|
end
|
489
498
|
ret
|
490
|
-
end
|
499
|
+
end
|
491
500
|
end
|
492
|
-
|
501
|
+
|
493
502
|
# unregister an array of email addresses
|
494
503
|
def self.unregister_emails(emails)
|
495
504
|
emails_hash = {}
|
496
505
|
emails.each {|e| emails_hash[hash_email(e)] = e}
|
497
|
-
begin
|
506
|
+
begin
|
498
507
|
unregister(emails_hash.keys).collect {|r| emails_hash[r]}
|
499
508
|
rescue
|
500
509
|
# re-raise with emails instead of hashes.
|
@@ -503,14 +512,14 @@ module Facebooker
|
|
503
512
|
raise e
|
504
513
|
end
|
505
514
|
end
|
506
|
-
|
515
|
+
|
507
516
|
def self.hash_email(email)
|
508
517
|
email = email.downcase.strip
|
509
518
|
crc=Zlib.crc32(email)
|
510
519
|
md5=Digest::MD5.hexdigest(email)
|
511
520
|
"#{crc}_#{md5}"
|
512
521
|
end
|
513
|
-
|
522
|
+
|
514
523
|
def self.cast_to_facebook_id(object)
|
515
524
|
if object.respond_to?(:facebook_id)
|
516
525
|
object.facebook_id
|
@@ -518,35 +527,35 @@ module Facebooker
|
|
518
527
|
object
|
519
528
|
end
|
520
529
|
end
|
521
|
-
|
530
|
+
|
522
531
|
def self.user_fields(fields = [])
|
523
532
|
valid_fields(fields)
|
524
533
|
end
|
525
|
-
|
534
|
+
|
526
535
|
def self.standard_fields(fields = [])
|
527
536
|
valid_fields(fields,STANDARD_FIELDS)
|
528
537
|
end
|
529
|
-
|
538
|
+
|
530
539
|
private
|
531
540
|
def publish(feed_story_or_action)
|
532
541
|
session.post(Facebooker::Feed::METHODS[feed_story_or_action.class.name.split(/::/).last], feed_story_or_action.to_params) == "1" ? true : false
|
533
542
|
end
|
534
|
-
|
543
|
+
|
535
544
|
def self.valid_fields(fields, allowable=FIELDS)
|
536
545
|
allowable.reject{|field_name| !fields.empty? && !fields.include?(field_name)}.join(',')
|
537
546
|
end
|
538
|
-
|
547
|
+
|
539
548
|
def collect(fields, allowable=FIELDS)
|
540
549
|
allowable.reject{|field_name| !fields.empty? && !fields.include?(field_name)}.join(',')
|
541
550
|
end
|
542
|
-
|
551
|
+
|
543
552
|
def profile_pic_album_id
|
544
553
|
merge_aid(-3, id)
|
545
554
|
end
|
546
|
-
|
555
|
+
|
547
556
|
def merge_aid(aid, uid)
|
548
557
|
(uid << 32) + (aid & 0xFFFFFFFF)
|
549
558
|
end
|
550
|
-
|
559
|
+
|
551
560
|
end
|
552
561
|
end
|
@@ -781,6 +781,14 @@ module Facebooker
|
|
781
781
|
tag "fb:date", stringify_vals({:t => time.to_i}.merge(options))
|
782
782
|
end
|
783
783
|
|
784
|
+
# Renders the Facebook bookmark button
|
785
|
+
#
|
786
|
+
# See http://wiki.developers.facebook.com/index.php/Fb:bookmark for
|
787
|
+
# more details
|
788
|
+
def fb_bookmark_button
|
789
|
+
content_tag "fb:bookmark"
|
790
|
+
end
|
791
|
+
|
784
792
|
# Renders a fb:fbml-attribute element
|
785
793
|
#
|
786
794
|
# Example:
|
@@ -109,6 +109,13 @@ module Facebooker
|
|
109
109
|
link_to_function text, js, *args
|
110
110
|
end
|
111
111
|
|
112
|
+
def fb_bookmark_link(text,url,*args)
|
113
|
+
js = update_page do |page|
|
114
|
+
page.call "FB.Connect.showBookmarkDialog",url
|
115
|
+
end
|
116
|
+
link_to_function text, js, *args
|
117
|
+
end
|
118
|
+
|
112
119
|
def fb_user_action(action, user_message = nil, prompt = "", callback = nil)
|
113
120
|
defaulted_callback = callback || "null"
|
114
121
|
update_page do |page|
|
@@ -11,24 +11,24 @@ module Facebooker
|
|
11
11
|
facebook_post facebook_redirect_url
|
12
12
|
end
|
13
13
|
|
14
|
-
def facebook_get(path,params={})
|
15
|
-
facebook_verb(:get,path,params)
|
14
|
+
def facebook_get(path, params={}, session=nil, flash=nil)
|
15
|
+
facebook_verb(:get, path, params, session, flash)
|
16
16
|
end
|
17
17
|
|
18
|
-
def facebook_post(path,params={})
|
19
|
-
facebook_verb(:post,path,params)
|
18
|
+
def facebook_post(path,params={}, session=nil, flash=nil)
|
19
|
+
facebook_verb(:post, path, params, session, flash)
|
20
20
|
end
|
21
21
|
|
22
|
-
def facebook_put(path,params={})
|
23
|
-
facebook_verb(:put,path,params)
|
22
|
+
def facebook_put(path,params={}, session=nil, flash=nil)
|
23
|
+
facebook_verb(:put, path, params, session, flash)
|
24
24
|
end
|
25
25
|
|
26
|
-
def facebook_delete(path,params={})
|
27
|
-
facebook_verb(:delete,path,params)
|
26
|
+
def facebook_delete(path,params={}, session=nil, flash=nil)
|
27
|
+
facebook_verb(:delete, path, params, session, flash)
|
28
28
|
end
|
29
29
|
|
30
|
-
def facebook_verb(verb,path, params={})
|
31
|
-
send verb, path, facebook_params(params).reverse_merge(:canvas => true)
|
30
|
+
def facebook_verb(verb, path, params={}, session=nil, flash=nil)
|
31
|
+
send verb, path, facebook_params(params).reverse_merge(:canvas => true), session, flash
|
32
32
|
end
|
33
33
|
|
34
34
|
def facebook_params(params = {})
|
data/lib/facebooker/session.rb
CHANGED
@@ -155,6 +155,8 @@ module Facebooker
|
|
155
155
|
optional_parameters << "&hide_checkbox=true" if options[:hide_checkbox]
|
156
156
|
optional_parameters << "&canvas=true" if options[:canvas]
|
157
157
|
optional_parameters << "&fbconnect=true" if options[:fbconnect]
|
158
|
+
optional_parameters << "&return_session=true" if options[:return_session]
|
159
|
+
optional_parameters << "&session_key_only=true" if options[:session_key_only]
|
158
160
|
optional_parameters << "&req_perms=#{options[:req_perms]}" if options[:req_perms]
|
159
161
|
optional_parameters.join
|
160
162
|
end
|
@@ -206,7 +208,7 @@ module Facebooker
|
|
206
208
|
def secure_with!(session_key, uid = nil, expires = nil, secret_from_session = nil)
|
207
209
|
@session_key = session_key
|
208
210
|
@uid = uid ? Integer(uid) : post('facebook.users.getLoggedInUser', :session_key => session_key)
|
209
|
-
@expires = Integer(expires)
|
211
|
+
@expires = expires ? Integer(expires) : 0
|
210
212
|
@secret_from_session = secret_from_session
|
211
213
|
end
|
212
214
|
|
data/lib/facebooker/version.rb
CHANGED
@@ -31,7 +31,7 @@ class Facebooker::ApplicationTest < Test::Unit::TestCase
|
|
31
31
|
<logo_url>http://photos-c.ak.facebook.com/photos-ak-sctm/v43/130/2413267546/app_1_2413267546_2324.gif</logo_url>
|
32
32
|
<developers list="true"/>
|
33
33
|
<company_name>iLike, inc</company_name>
|
34
|
-
<description>iLike lets you add music to your profile and find your favorite concerts (not to mention see who else is going!). Bonus: Use it to get free mp3
|
34
|
+
<description>iLike lets you add music to your profile and find your favorite concerts (not to mention see who else is going!). Bonus: Use it to get free mp3's that match your tastes and try to beat your friends at the Music Challenge.</description>
|
35
35
|
<daily_active_users>392008</daily_active_users>
|
36
36
|
<weekly_active_users>1341749</weekly_active_users>
|
37
37
|
<monthly_active_users>3922784</monthly_active_users>
|
@@ -16,14 +16,14 @@ class Facebooker::UserTest < Test::Unit::TestCase
|
|
16
16
|
|
17
17
|
def test_has_permission
|
18
18
|
expect_http_posts_with_responses(has_app_permission_response_xml)
|
19
|
-
assert @user.has_permission?("status_update")
|
19
|
+
assert @user.has_permission?("status_update")
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_has_permissions
|
23
|
-
expect_http_posts_with_responses(has_app_permission_response_xml, has_app_permission_response_xml)
|
24
|
-
assert @user.has_permissions?(["status_update", "read_stream"])
|
25
|
-
end
|
26
|
-
|
23
|
+
expect_http_posts_with_responses(has_app_permission_response_xml, has_app_permission_response_xml)
|
24
|
+
assert @user.has_permissions?(["status_update", "read_stream"])
|
25
|
+
end
|
26
|
+
|
27
27
|
def test_can_ask_user_if_he_or_she_is_friends_with_another_user
|
28
28
|
assert(@user.friends_with?(@other_user))
|
29
29
|
end
|
@@ -146,6 +146,17 @@ class Facebooker::UserTest < Test::Unit::TestCase
|
|
146
146
|
assert_nil(options[:attachment])
|
147
147
|
assert_equal(options[:action_links], [:text => 'Link', :href => 'http://example.com'].to_json )
|
148
148
|
end
|
149
|
+
|
150
|
+
def test_prepare_publish_to_options_to_page_on_behave_of_page
|
151
|
+
page_id = 12345678
|
152
|
+
options = @user.prepare_publish_to_options(@user, {:uid => 12345678, :post_as_page => true, :message => 'Hey there', :action_links => [:text => 'Link', :href => 'http://example.com']})
|
153
|
+
assert_equal(options[:uid], page_id)
|
154
|
+
assert_nil(options[:target_id])
|
155
|
+
assert_equal(options[:message], 'Hey there')
|
156
|
+
assert_nil(options[:attachment])
|
157
|
+
assert_equal(options[:action_links], [:text => 'Link', :href => 'http://example.com'].to_json )
|
158
|
+
end
|
159
|
+
|
149
160
|
def test_publish_to
|
150
161
|
@user = Facebooker::User.new(548871286, @session)
|
151
162
|
expect_http_posts_with_responses(example_profile_publish_to_get_xml)
|
@@ -162,7 +173,7 @@ class Facebooker::UserTest < Test::Unit::TestCase
|
|
162
173
|
expect_http_posts_with_responses(example_comment_on_response)
|
163
174
|
assert_equal('703826862_78463536863', @user.comment_on('703826862_78463536862', :message => 'that was hilarious!'))
|
164
175
|
end
|
165
|
-
|
176
|
+
|
166
177
|
def test_can_send_email
|
167
178
|
@user.expects(:send_email).with("subject", "body text")
|
168
179
|
@user.send_email("subject", "body text")
|
@@ -378,18 +389,18 @@ class Facebooker::UserTest < Test::Unit::TestCase
|
|
378
389
|
<stream_publish_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">703826862_78463536862</stream_publish_response>
|
379
390
|
eoxml
|
380
391
|
end
|
381
|
-
|
392
|
+
|
382
393
|
def example_comment_on_response
|
383
394
|
<<-eoxml
|
384
395
|
<?xml version="1.0" encoding="UTF-8"?>
|
385
396
|
<stream_addComment_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">703826862_78463536863</stream_addComment_response>
|
386
397
|
eoxml
|
387
|
-
end
|
388
|
-
|
398
|
+
end
|
399
|
+
|
389
400
|
def example_events_rsvp_xml
|
390
401
|
<<-E
|
391
402
|
<?xml version="1.0" encoding="UTF-8"?>
|
392
|
-
<events_rsvp_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
403
|
+
<events_rsvp_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
393
404
|
xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">1
|
394
405
|
</events_rsvp_response>
|
395
406
|
E
|
@@ -1099,6 +1099,10 @@ class RailsHelperTest < Test::Unit::TestCase
|
|
1099
1099
|
assert_equal @h.fb_logout_link("Logout","My URL"),"<a href=\"#\" onclick=\"FB.Connect.logoutAndRedirect("My URL");; return false;\">Logout</a>"
|
1100
1100
|
end
|
1101
1101
|
|
1102
|
+
def test_fb_bookmark_link
|
1103
|
+
assert_equal @h.fb_bookmark_link("Bookmark","My URL"),"<a href=\"#\" onclick=\"FB.Connect.showBookmarkDialog("My URL");; return false;\">Bookmark</a>"
|
1104
|
+
end
|
1105
|
+
|
1102
1106
|
def test_fb_user_action_with_literal_callback
|
1103
1107
|
action = Facebooker::Rails::Publisher::UserAction.new
|
1104
1108
|
assert_equal "FB.Connect.showFeedDialog(null, null, null, null, null, FB.RequireConnect.promptConnect, function() {alert('hi')}, \"prompt\", #{{"value" => "message"}.to_json});",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: facebooker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.56
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chad Fowler
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2009-
|
17
|
+
date: 2009-12-04 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|