Skip to content

Instantly share code, notes, and snippets.

@amyroi
Last active October 14, 2015 20:18
Show Gist options
  • Save amyroi/0df44182ae62a0ef2862 to your computer and use it in GitHub Desktop.
Save amyroi/0df44182ae62a0ef2862 to your computer and use it in GitHub Desktop.
class Facebook::Notification
attr_accessor :canvas_auth, :graph
def initialize
conf = Rails.configuration.facebook_canvas
@canvas_auth = Koala::Facebook::OAuth.new(conf[:app_id], conf[:app_secret])
@graph = Koala::Facebook::API::new(canvas_auth.get_app_access_token, conf[:app_secret])
end
def user_join(user)
graph.put_connections user.facebook_resource.friend_uids.join(','),
'notifications',
template: "#{app_name}に登録しました!#{user.facebook_resource.name}さんのページをみてみましょう!",
href: "users/#{user.id}"
end
def published_plan(user, plan)
graph.put_connections user.facebook_resource.friend_uids.join(','),
'notifications',
template: "友達の#{user.facebook_resource.name}さんが、新しいプラン「#{plan.title}」を投稿しました!さっそくみてみましょう!",
href: "plans/#{plan.id}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment