lib/facebooker/session.rb in facebooker-1.0.44 vs lib/facebooker/session.rb in facebooker-1.0.48
- old
+ new
@@ -98,15 +98,15 @@
Thread.current['facebook_session'] = session
end
def login_url(options={})
options = default_login_url_options.merge(options)
- "#{Facebooker.login_url_base(@api_key)}#{login_url_optional_parameters(options)}"
+ "#{Facebooker.login_url_base}#{login_url_optional_parameters(options)}"
end
def install_url(options={})
- "#{Facebooker.install_url_base(@api_key)}#{install_url_optional_parameters(options)}"
+ "#{Facebooker.install_url_base}#{install_url_optional_parameters(options)}"
end
# The url to get user to approve extended permissions
# http://wiki.developers.facebook.com/index.php/Extended_permission
#
@@ -120,11 +120,13 @@
# * 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 install_url_optional_parameters(options)
optional_parameters = []
optional_parameters += add_next_parameters(options)
@@ -143,10 +145,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 +271,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 +366,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
@@ -410,9 +433,21 @@
unless full_story_template.blank?
parameters[:full_story_template] = full_story_template.to_json
end
post("facebook.feed.registerTemplateBundle", parameters, false)
+ end
+
+ ##
+ # 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