Skip to content

Instantly share code, notes, and snippets.

@silviopaganini
Created November 23, 2013 19:05
Show Gist options
  • Save silviopaganini/7618608 to your computer and use it in GitHub Desktop.
Save silviopaganini/7618608 to your computer and use it in GitHub Desktop.
Facebook notification
@sendTreeNow : (id, tree_id, complete, fail) =>
# TODO get message data
template = "@[#{Facebook.user.id}] gifted you a tree in the Amazon. Name it now."
url = (window or document).location.origin + "trees/#{tree_id}"
$.get "https://graph.facebook.com/oauth/access_token?client_id=#{window.config.fb_app}&client_secret=#{window.config.fb_secret}&grant_type=client_credentials", (data) =>
str = "https://graph.facebook.com/"
str += "#{id}/"
str += "notifications/"
str += "?#{data}"
str += "&template=#{template}"
str += "&href=#{url}"
$.post str, (data) =>
if(data.success)
complete?()
else
fail?()
null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment