lib/facebooker/session.rb in taweili-facebooker-1.0.47 vs lib/facebooker/session.rb in taweili-facebooker-1.0.50
- old
+ new
@@ -120,13 +120,22 @@
# * create_event
# * rsvp_event
# * sms
def permission_url(permission,options={})
options = default_login_url_options.merge(options)
- "http://#{Facebooker.www_server_base_url}/authorize.php?api_key=#{@api_key}&v=1.0&ext_perm=#{permission}#{install_url_optional_parameters(options)}"
+ options = add_next_parameters(options)
+ options << "&ext_perm=#{permission}"
+ "#{Facebooker.permission_url_base}#{options.join}"
end
+ def connect_permission_url(permission,options={})
+ options = default_login_url_options.merge(options)
+ options = add_next_parameters(options)
+ options << "&ext_perm=#{permission}"
+ "#{Facebooker.connect_permission_url_base}#{options.join}"
+ end
+
def install_url_optional_parameters(options)
optional_parameters = []
optional_parameters += add_next_parameters(options)
optional_parameters.join
end
@@ -143,10 +152,12 @@
optional_parameters = []
optional_parameters += add_next_parameters(options)
optional_parameters << "&skipcookie=true" if options[:skip_cookie]
optional_parameters << "&hide_checkbox=true" if options[:hide_checkbox]
optional_parameters << "&canvas=true" if options[:canvas]
+ optional_parameters << "&fbconnect=true" if options[:fbconnect]
+ optional_parameters << "&req_perms=#{options[:req_perms]}" if options[:req_perms]
optional_parameters.join
end
def default_login_url_options
{}
@@ -267,10 +278,27 @@
Event.from_hash(hash)
end
end
end
+ # Creates an event with the event_info hash and an optional Net::HTTP::MultipartPostFile for the event picture
+ # Returns the eid of the newly created event
+ # http://wiki.developers.facebook.com/index.php/Events.create
+ def create_event(event_info, multipart_post_file = nil)
+ post_file('facebook.events.create', :event_info => event_info.to_json, nil => multipart_post_file)
+ end
+
+ # Cancel an event
+ # http://wiki.developers.facebook.com/index.php/Events.cancel
+ # E.g:
+ # @session.cancel_event('100321123', :cancel_message => "It's raining...")
+ # # => Returns true if all went well
+ def cancel_event(eid, options = {})
+ result = post('facebook.events.cancel', options.merge(:eid => eid))
+ result == '1' ? true : false
+ end
+
def event_members(eid)
@members = post('facebook.events.getMembers', :eid => eid) do |response|
response.map do |attendee_hash|
Event::Attendance.from_hash(attendee_hash)
end
@@ -345,11 +373,13 @@
def get_photos(pids = nil, subj_id = nil, aid = nil)
if [subj_id, pids, aid].all? {|arg| arg.nil?}
raise ArgumentError, "Can't get a photo without a picture, album or subject ID"
end
- @photos = post('facebook.photos.get', :subj_id => subj_id, :pids => pids, :aid => aid ) do |response|
+ # We have to normalize params orherwise FB complain about signature
+ params = {:pids => pids, :subj_id => subj_id, :aid => aid}.delete_if { |k,v| v.nil? }
+ @photos = post('facebook.photos.get', params ) do |response|
response.map do |hash|
Photo.from_hash(hash)
end
end
end
@@ -418,9 +448,13 @@
# Deactivate a template bundle with Facebook.
# Returns true if a bundle with the specified id is active and owned by this app.
# Useful to avoid exceeding the 100 templates/app limit.
def deactivate_template_bundle_by_id(template_bundle_id)
post("facebook.feed.deactivateTemplateBundleByID", {:template_bundle_id => template_bundle_id.to_s}, false)
+ end
+
+ def active_template_bundles
+ post("facebook.feed.getRegisteredTemplateBundles",{},false)
end
##
# publish a previously rendered template bundle
# see http://wiki.developers.facebook.com/index.php/Feed.publishUserAction