require 'koala' module Silvermoon module Notifier class Facebook < Base def identifier :facebook end def notify(title, content, url, extras = {}) Rails.logger.info("Notifying Facebook: #{title}, #{content}, #{url}") comment = extras.delete(:comment) graph.put_wall_post(comment, {:link => url, :description => content, :picture => ''}.reverse_merge(extras), nil, :use_ssl => false) end def oauth @oauth ||= ::Koala::Facebook::OAuth.new(config['app_id'], config['app_secret']) end def graph @graph ||= ::Koala::Facebook::GraphAPI.new(access_token) end def access_token @access_token ||= begin token = oauth.get_app_access_token raise "Cannot obtain access token" unless token token end end end end end