Class: Courier::Service::Facebook
- Defined in:
- lib/courier/service/facebook.rb
Constant Summary collapse
- FACEBOOK_PROPERTY_ATTRS =
[:from, :to, :picture, :link, :name, :caption, :description, :message, :source, :icon, :attribution, :actions, :privacy, :targeting]
Instance Method Summary collapse
-
#deliver_message(message) ⇒ Object
message.options are all available options from developers.facebook.com/docs/reference/api/post/.
-
#initialize ⇒ Facebook
constructor
A new instance of Facebook.
Methods inherited from Base
#check_args, config, configure, #deliver_all!, inherited, #message, #messages, #name, #to_label, #to_s
Constructor Details
#initialize ⇒ Facebook
Returns a new instance of Facebook.
8 9 10 11 12 |
# File 'lib/courier/service/facebook.rb', line 8 def initialize raise "No Koala defined. Add gem 'koala' to your Gemfile. " unless defined? Koala attr_accessor={} super end |
Instance Method Details
#deliver_message(message) ⇒ Object
message.options are all available options from developers.facebook.com/docs/reference/api/post/
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/courier/service/facebook.rb', line 18 def () args = .[:facebook_properties] || ..slice(FACEBOOK_PROPERTY_ATTRS) args[:message] ||= .[:text] || Courier.template(.template). get_text(.service, .) token = args[:token] token ||= .owner.facebook_token if .owner.respond_to?(:facebook_token) return true unless token to = args[:to] || (.owner.respond_to?(:facebook_id) ? .owner.facebook_id : nil) || 'me' # Settings.omniauth.facebook.app_id, Settings.omniauth.facebook.secret # Это post_on_wall Koala::Facebook::GraphAPI.new(token).put_object(to, "feed", args) end |