Skip to content

Instantly share code, notes, and snippets.

@nov
Created January 15, 2011 04:37
Show Gist options
  • Save nov/780701 to your computer and use it in GitHub Desktop.
Save nov/780701 to your computer and use it in GitHub Desktop.
Query permissions using FQL
require 'fb_graph'
permission_candidates = [
:email,
:sms,
:read_stream,
:publish_stream
]
permissions = FbGraph::Query.new(
"SELECT #{permission_candidates.join(',')} FROM permissions WHERE uid = me()"
).fetch(ACCESS_TOKEN)
permission_candidates.each do |candidate|
answer = case permissions.first[candidate]
when 0
"YES"
when 1
"NO"
end
puts "Has #{candidate} permission? => #{answer}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment